mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Issue #4: Fix invalid leading spaces with attributes
This commit is contained in:
parent
6703518300
commit
e481813300
1 changed files with 3 additions and 3 deletions
|
|
@ -89,14 +89,13 @@ func (b *atxHeadingParser) Open(parent ast.Node, reader text.Reader, pc Context)
|
||||||
return nil, NoChildren
|
return nil, NoChildren
|
||||||
}
|
}
|
||||||
start := i + l
|
start := i + l
|
||||||
|
origstart := start
|
||||||
stop := len(line) - util.TrimRightSpaceLength(line)
|
stop := len(line) - util.TrimRightSpaceLength(line)
|
||||||
|
|
||||||
node := ast.NewHeading(level)
|
node := ast.NewHeading(level)
|
||||||
parsed := false
|
parsed := false
|
||||||
if b.Attribute { // handles special case like ### heading ### {#id}
|
if b.Attribute { // handles special case like ### heading ### {#id}
|
||||||
if line[start] == '#' {
|
start--
|
||||||
start--
|
|
||||||
}
|
|
||||||
closureOpen := -1
|
closureOpen := -1
|
||||||
closureClose := -1
|
closureClose := -1
|
||||||
for i := start; i < stop; {
|
for i := start; i < stop; {
|
||||||
|
|
@ -141,6 +140,7 @@ func (b *atxHeadingParser) Open(parent ast.Node, reader text.Reader, pc Context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !parsed {
|
if !parsed {
|
||||||
|
start = origstart
|
||||||
stop := len(line) - util.TrimRightSpaceLength(line)
|
stop := len(line) - util.TrimRightSpaceLength(line)
|
||||||
if stop <= start { // empty headings like '##[space]'
|
if stop <= start { // empty headings like '##[space]'
|
||||||
stop = start + 1
|
stop = start + 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue