diff --git a/_test/extra.txt b/_test/extra.txt index 197a3f5..96715df 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -409,3 +409,10 @@ hello\x00world

x

x

//= = = = = = = = = = = = = = = = = = = = = = = =// + +28: Single # is a heading level 1 +//- - - - - - - - -// +# +//- - - - - - - - -// +

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/atx_heading.go b/parser/atx_heading.go index 2526088..13a198b 100644 --- a/parser/atx_heading.go +++ b/parser/atx_heading.go @@ -91,6 +91,9 @@ func (b *atxHeadingParser) Open(parent ast.Node, reader text.Reader, pc Context) if i == pos || level > 6 { return nil, NoChildren } + if i == len(line) { // alone '#' (without a new line character) + return ast.NewHeading(level), NoChildren + } l := util.TrimLeftSpaceLength(line[i:]) if l == 0 { return nil, NoChildren