parseRule: treat the occurrence of a parse error as a valid condition
The previous implementation was too strict. A parse error can occur if the input is a single line consisting of spaces and tabs only.
This commit is contained in:
parent
ee7958ce49
commit
6402ae5405
@ -81,6 +81,9 @@ func (p *Parser) Markdown(src io.Reader, f Formatter) {
|
|||||||
L:
|
L:
|
||||||
for {
|
for {
|
||||||
tree := p.parseRule(ruleDocblock, s)
|
tree := p.parseRule(ruleDocblock, s)
|
||||||
|
if tree == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
s = p.yy.ResetBuffer("")
|
s = p.yy.ResetBuffer("")
|
||||||
tree = p.processRawBlocks(tree)
|
tree = p.processRawBlocks(tree)
|
||||||
f.FormatBlock(tree)
|
f.FormatBlock(tree)
|
||||||
@ -97,12 +100,12 @@ func (p *Parser) parseRule(rule int, s string) (tree *element) {
|
|||||||
if p.yy.ResetBuffer(s) != "" {
|
if p.yy.ResetBuffer(s) != "" {
|
||||||
log.Fatalf("Buffer not empty")
|
log.Fatalf("Buffer not empty")
|
||||||
}
|
}
|
||||||
if err := p.yy.Parse(rule); err != nil {
|
err := p.yy.Parse(rule)
|
||||||
log.Fatalln("markdown:", err)
|
|
||||||
}
|
|
||||||
switch rule {
|
switch rule {
|
||||||
case ruleDoc, ruleDocblock:
|
case ruleDoc, ruleDocblock:
|
||||||
|
if err == nil {
|
||||||
tree = p.yy.state.tree
|
tree = p.yy.state.tree
|
||||||
|
}
|
||||||
p.yy.state.tree = nil
|
p.yy.state.tree = nil
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user