Skip to content

Commit

Permalink
Add support for a "C++" tag name
Browse files Browse the repository at this point in the history
  • Loading branch information
msp301 committed Mar 10, 2024
1 parent b71c1a2 commit b628b7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion parser/examples/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ With #several #tags mentioned

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

\#ignored
4 changes: 2 additions & 2 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func TestParseDuplicateTags(t *testing.T) {
got := Parse("examples/tags.md")
want := []Note{
{
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",
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",
File: "examples/tags.md",
Id: 202204192322,
Links: nil,
Tags: []string{"#test", "#several", "#tags", "#Order", "#C#"},
Tags: []string{"#test", "#several", "#tags", "#Order", "#C#", "#C++"},
Title: "Test tags mentioned multiple times",
},
}
Expand Down
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var LinkRegex *regexp.Regexp

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

Expand Down

0 comments on commit b628b7b

Please sign in to comment.