From 6402ae540509298a81e83ba8e077b49a2d2b19b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Teichgr=C3=A4ber?= Date: Wed, 30 May 2012 01:29:37 +0200 Subject: [PATCH] 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. --- markdown.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/markdown.go b/markdown.go index 601f940..337e289 100644 --- a/markdown.go +++ b/markdown.go @@ -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