From 1306649a6530dfa54294458ef720a64013072a05 Mon Sep 17 00:00:00 2001 From: yuin Date: Sat, 11 Sep 2021 11:51:43 +0900 Subject: [PATCH] Fix #245 - 6 --- _test/extra.txt | 7 +++++++ parser/atx_heading.go | 3 +++ 2 files changed, 10 insertions(+) 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