Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 6402ae540509298a81e83ba8e077b49a2d2b19b3 1 parent ee7958c
@knieriem authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 markdown.go
View
11 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
Please sign in to comment.
Something went wrong with that request. Please try again.