fix: allow ampersand in tags to support compound tags

This commit is contained in:
Johnny 2026-02-11 22:55:45 +08:00
parent f7d370dba1
commit 177a74e82b
3 changed files with 9 additions and 2 deletions

View File

@ -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
}

View File

@ -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",

View File

@ -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 }> {