Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: allow ampersand in tags to support compound tags

Johnny177a74e82bcf
diff --git a/plugin/markdown/parser/tag.go b/plugin/markdown/parser/tag.go
index 15dc9ca4c..22ad4f7a4 100644
--- a/plugin/markdown/parser/tag.go
+++ b/plugin/markdown/parser/tag.go
@@ -51,7 +51,8 @@ func isValidTagRune(r rune) bool {
// Underscore: word separation (snake_case)
// Hyphen: word separation (kebab-case)
// Forward slash: hierarchical tags (category/subcategory)
- if r == '_' || r == '-' || r == '/' {
+ // Ampersand: compound tags (science&tech)
+ if r == '_' || r == '-' || r == '/' || r == '&' {
return true
}
diff --git a/plugin/markdown/parser/tag_test.go b/plugin/markdown/parser/tag_test.go
index 6150c4487..a6015f4d1 100644
--- a/plugin/markdown/parser/tag_test.go
+++ b/plugin/markdown/parser/tag_test.go
@@ -30,6 +30,12 @@ func TestTagParser(t *testing.T) {
expectedTag: "work-notes",
shouldParse: true,
},
+ {
+ name: "tag with ampersand",
+ input: "#science&tech",
+ expectedTag: "science&tech",
+ shouldParse: true,
+ },
{
name: "tag with underscore",
input: "#2024_plans",
diff --git a/web/src/utils/remark-plugins/remark-tag.ts b/web/src/utils/remark-plugins/remark-tag.ts
index 3a6ad0c00..24a0efbcb 100644
--- a/web/src/utils/remark-plugins/remark-tag.ts
+++ b/web/src/utils/remark-plugins/remark-tag.ts
@@ -18,7 +18,7 @@ function isTagChar(char: string): boolean {
return true;
}
- return char === "_" || char === "-" || char === "/";
+ return char === "_" || char === "-" || char === "/" || char === "&";
}
function parseTagsFromText(text: string): Array<{ type: "text"; value: string } | { type: "tag"; value: string }> {