Skip to content

Commit b628b7b

Browse files
committed
Add support for a "C++" tag name
1 parent b71c1a2 commit b628b7b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

parser/examples/tags.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ With #several #tags mentioned
1010

1111
#Order is preserved.
1212
This is a tag in quotes "#1-1"
13-
#C# is a valid tag.
13+
#C# and #C++ are valid tags.
1414
Tag in a URL: http://example.com/#foo
1515

1616
\#ignored

parser/parser_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ func TestParseDuplicateTags(t *testing.T) {
4343
got := Parse("examples/tags.md")
4444
want := []Note{
4545
{
46-
Content: "This is a #test file. #test\nWith #several #tags mentioned\n#several times.\n\n## Subheading\n\n#Order is preserved.\nThis is a tag in quotes \"#1-1\"\n#C# is a valid tag.\nTag in a URL: http://example.com/#foo\n\n\\#ignored",
46+
Content: "This is a #test file. #test\nWith #several #tags mentioned\n#several times.\n\n## Subheading\n\n#Order is preserved.\nThis is a tag in quotes \"#1-1\"\n#C# and #C++ are valid tags.\nTag in a URL: http://example.com/#foo\n\n\\#ignored",
4747
File: "examples/tags.md",
4848
Id: 202204192322,
4949
Links: nil,
50-
Tags: []string{"#test", "#several", "#tags", "#Order", "#C#"},
50+
Tags: []string{"#test", "#several", "#tags", "#Order", "#C#", "#C++"},
5151
Title: "Test tags mentioned multiple times",
5252
},
5353
}

util/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var LinkRegex *regexp.Regexp
1111

1212
func init() {
1313
IdRegex = regexp.MustCompile(`^(\d{12})$`)
14-
TagRegex = regexp.MustCompile(`(?:^|\s+)(#+\.?[0-9a-zA-Z_-][#0-9a-zA-Z_-]+)`)
14+
TagRegex = regexp.MustCompile(`(?:^|\s+)(#+\.?[0-9a-zA-Z_-][#0-9a-zA-Z_\-+]+)`)
1515
LinkRegex = regexp.MustCompile(`\B\[\[([\d\s\/:]+)\]\]`)
1616
}
1717

0 commit comments

Comments
 (0)