diff --git a/plugin/gomark/parser/heading.go b/plugin/gomark/parser/heading.go index 1b228dbf..284c8882 100644 --- a/plugin/gomark/parser/heading.go +++ b/plugin/gomark/parser/heading.go @@ -36,11 +36,11 @@ func (*HeadingParser) Match(tokens []*tokenizer.Token) (int, bool) { cursor++ contentTokens := []*tokenizer.Token{} for _, token := range tokens[cursor:] { + contentTokens = append(contentTokens, token) + cursor++ if token.Type == tokenizer.Newline { break } - contentTokens = append(contentTokens, token) - cursor++ } if len(contentTokens) == 0 { return 0, false diff --git a/plugin/gomark/parser/heading_test.go b/plugin/gomark/parser/heading_test.go index 759c1d18..47cee835 100644 --- a/plugin/gomark/parser/heading_test.go +++ b/plugin/gomark/parser/heading_test.go @@ -53,6 +53,7 @@ Hello World`, &ast.Text{ Content: "123 ", }, + &ast.LineBreak{}, }, }, }, diff --git a/plugin/gomark/parser/horizontal_rule.go b/plugin/gomark/parser/horizontal_rule.go index 0f104539..a3db6d1d 100644 --- a/plugin/gomark/parser/horizontal_rule.go +++ b/plugin/gomark/parser/horizontal_rule.go @@ -26,7 +26,10 @@ func (*HorizontalRuleParser) Match(tokens []*tokenizer.Token) (int, bool) { if len(tokens) > 3 && tokens[3].Type != tokenizer.Newline { return 0, false } - return 3, true + if len(tokens) == 3 { + return 3, true + } + return 4, true } func (p *HorizontalRuleParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) { diff --git a/plugin/gomark/parser/horizontal_rule_test.go b/plugin/gomark/parser/horizontal_rule_test.go index 1cc34428..d191ae8f 100644 --- a/plugin/gomark/parser/horizontal_rule_test.go +++ b/plugin/gomark/parser/horizontal_rule_test.go @@ -20,6 +20,12 @@ func TestHorizontalRuleParser(t *testing.T) { Symbol: "-", }, }, + { + text: "---\naaa", + horizontalRule: &ast.HorizontalRule{ + Symbol: "-", + }, + }, { text: "****", horizontalRule: nil,