Commit 177a74e8 authored by Johnny's avatar Johnny

fix: allow ampersand in tags to support compound tags

parent f7d370db
...@@ -51,7 +51,8 @@ func isValidTagRune(r rune) bool { ...@@ -51,7 +51,8 @@ func isValidTagRune(r rune) bool {
// Underscore: word separation (snake_case) // Underscore: word separation (snake_case)
// Hyphen: word separation (kebab-case) // Hyphen: word separation (kebab-case)
// Forward slash: hierarchical tags (category/subcategory) // Forward slash: hierarchical tags (category/subcategory)
if r == '_' || r == '-' || r == '/' { // Ampersand: compound tags (science&tech)
if r == '_' || r == '-' || r == '/' || r == '&' {
return true return true
} }
......
...@@ -30,6 +30,12 @@ func TestTagParser(t *testing.T) { ...@@ -30,6 +30,12 @@ func TestTagParser(t *testing.T) {
expectedTag: "work-notes", expectedTag: "work-notes",
shouldParse: true, shouldParse: true,
}, },
{
name: "tag with ampersand",
input: "#science&tech",
expectedTag: "science&tech",
shouldParse: true,
},
{ {
name: "tag with underscore", name: "tag with underscore",
input: "#2024_plans", input: "#2024_plans",
......
...@@ -18,7 +18,7 @@ function isTagChar(char: string): boolean { ...@@ -18,7 +18,7 @@ function isTagChar(char: string): boolean {
return true; return true;
} }
return char === "_" || char === "-" || char === "/"; return char === "_" || char === "-" || char === "/" || char === "&";
} }
function parseTagsFromText(text: string): Array<{ type: "text"; value: string } | { type: "tag"; value: string }> { function parseTagsFromText(text: string): Array<{ type: "text"; value: string } | { type: "tag"; value: string }> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment