Skip to content

Commit 2589b6a

Browse files
committed
fix: #541
1 parent 779298d commit 2589b6a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

_test/extra.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,3 +876,10 @@ text" /></p>
876876
</li>
877877
</ul>
878878
//= = = = = = = = = = = = = = = = = = = = = = = =//
879+
880+
70: Single letter ATX heading
881+
//- - - - - - - - -//
882+
# A
883+
//- - - - - - - - -//
884+
<h1>A</h1>
885+
//= = = = = = = = = = = = = = = = = = = = = = = =//

parser/atx_heading.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,13 @@ func (b *atxHeadingParser) Open(parent ast.Node, reader text.Reader, pc Context)
126126
i = stop - 1
127127
for ; line[i] == '#' && i > 0; i-- {
128128
}
129-
if i == 0 { // empty headings like '### ###'
129+
if i == 0 && line[0] == '#' { // empty headings like '### ###'
130130
reader.AdvanceToEOL()
131131
return node, NoChildren
132132
}
133-
if i == 0 || util.IsSpace(line[i]) {
133+
if i != stop-1 && util.IsSpace(line[i]) {
134134
stop = i
135135
stop -= util.TrimRightSpaceLength(line[0:stop])
136-
137136
}
138137
}
139138
hl.Stop = hl.Start + stop

0 commit comments

Comments
 (0)