Skip to content

Commit

Permalink
feat(parser): support colons in element names (#723)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrian Hesketh <adrianhesketh@hushmail.com>
Co-authored-by: Adrian Hesketh <a-h@users.noreply.github.com>
  • Loading branch information
3 people authored May 8, 2024
1 parent e2ceaa3 commit 7d8287e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.681
0.2.682
2 changes: 1 addition & 1 deletion parser/v2/elementparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (attributesParser) Parse(in *parse.Input) (attributes []Attribute, ok bool,
// Element name.
var (
elementNameFirst = "abcdefghijklmnopqrstuvwxyz"
elementNameSubsequent = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
elementNameSubsequent = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-:"
elementNameParser = parse.Func(func(in *parse.Input) (name string, ok bool, err error) {
start := in.Index()
var prefix, suffix string
Expand Down
25 changes: 25 additions & 0 deletions parser/v2/elementparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@ func TestAttributeParser(t *testing.T) {
},
},
},
{
name: "element: colon in name",
input: `<maps:map>`,
parser: StripType(elementOpenTagParser),
expected: elementOpenTag{
Name: "maps:map",
NameRange: Range{
From: Position{Index: 1, Line: 0, Col: 1},
To: Position{Index: 9, Line: 0, Col: 9},
},
},
},
{
name: "element: colon in name, closing",
input: `<maps:map>Content</maps:map>`,
parser: StripType(element),
expected: Element{
Name: "maps:map",
NameRange: Range{
From: Position{Index: 1, Line: 0, Col: 1},
To: Position{Index: 9, Line: 0, Col: 9},
},
Children: []Node{Text{Value: "Content"}},
},
},
{
name: "element: open with hyperscript attribute",
input: `<div _="show = true">`,
Expand Down

0 comments on commit 7d8287e

Please sign in to comment.