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:
Michael Teichgräber 2012-05-30 01:29:37 +02:00
parent ee7958ce49
commit 6402ae5405

View File

@ -81,6 +81,9 @@ func (p *Parser) Markdown(src io.Reader, f Formatter) {
L:
for {
tree := p.parseRule(ruleDocblock, s)
if tree == nil {
break
}
s = p.yy.ResetBuffer("")
tree = p.processRawBlocks(tree)
f.FormatBlock(tree)
@ -97,12 +100,12 @@ func (p *Parser) parseRule(rule int, s string) (tree *element) {
if p.yy.ResetBuffer(s) != "" {
log.Fatalf("Buffer not empty")
}
if err := p.yy.Parse(rule); err != nil {
log.Fatalln("markdown:", err)
}
err := p.yy.Parse(rule)
switch rule {
case ruleDoc, ruleDocblock:
tree = p.yy.state.tree
if err == nil {
tree = p.yy.state.tree
}
p.yy.state.tree = nil
}
return