Skip to content

Commit

Permalink
fix: inline node order
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jul 13, 2024
1 parent e1871ea commit e5b687d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser/html_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (*HTMLElementParser) Match(tokens []*tokenizer.Token) (ast.Node, int) {
return nil, 0
}

matchedTokens := tokens[:greaterThanIndex]
matchedTokens := tokens[:greaterThanIndex+1]
attributeTokens := matchedTokens[2 : greaterThanIndex-2]
// TODO: Implement attribute parser.
if len(attributeTokens) != 0 {
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func ParseBlockWithParsers(tokens []*tokenizer.Token, blockParsers []BlockParser

var defaultInlineParsers = []InlineParser{
NewEscapingCharacterParser(),
NewHTMLElementParser(),
NewBoldItalicParser(),
NewImageParser(),
NewLinkParser(),
Expand All @@ -79,7 +80,6 @@ var defaultInlineParsers = []InlineParser{
NewReferencedContentParser(),
NewTagParser(),
NewStrikethroughParser(),
NewHTMLElementParser(),
NewLineBreakParser(),
NewTextParser(),
}
Expand Down
18 changes: 18 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,24 @@ func TestParser(t *testing.T) {
},
},
},
{
text: "Hello <br /> world",
nodes: []ast.Node{
&ast.Paragraph{
Children: []ast.Node{
&ast.Text{
Content: "Hello ",
},
&ast.HTMLElement{
TagName: "br",
},
&ast.Text{
Content: " world",
},
},
},
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit e5b687d

Please sign in to comment.