fix: allow ampersand in tags to support compound tags
This commit is contained in:
parent
f7d370dba1
commit
177a74e82b
3 changed files with 9 additions and 2 deletions
|
|
@ -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) {
|
||||||
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 {
|
||||||
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 }> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue