Permalink
Browse files

Simplified list parsers.

  • Loading branch information...
1 parent 4438c33 commit 8a4f5a17d914a2ab7cbae40fa4664a33b9336f7e @jgm committed May 13, 2008
Showing with 7 additions and 12 deletions.
  1. +7 −12 Markdown.hs
View
@@ -215,25 +215,20 @@ doc = mdo
bulletListLoose <- newRule $ many1 ((bulletListItem <<- many blankline) ## (\s -> [Markdown $ s ++ "\n\n"])) ##
BulletList
bulletListItem <- newRule $ doesNotMatch horizontalRule ->> bullet ->>
- bulletListBlock <++> (many bulletListContinuationBlock ## concat)
- bulletListBlock <- newRule $ anyline <++> (many (doesNotMatch (optional indent ->> (bulletListItem // orderedListItem))
- ->> doesNotMatch blankline ->> optionallyIndentedLine) ## concat)
- bulletListContinuationBlock <- newRule $ ((many1 blankline ## concat) // unit "\0") <++>
- (many1 (indent ->> bulletListBlock) ## concat)
+ listBlock <++> (many listContinuationBlock ## concat)
+ listBlock <- newRule $ anyline <++> (many (doesNotMatch (optional indent ->> (bulletListItem // orderedListItem))
+ ->> doesNotMatch blankline ->> doesNotMatch (indent ->> (bullet // enumerator)) ->>
+ optionallyIndentedLine) ## concat)
+ listContinuationBlock <- newRule $ ((many1 blankline ## concat) // unit "\0") <++>
+ (many1 (indent ->> listBlock) ## concat)
enumerator <- newRule $ nonindentSpace ->> many1 digit <<- char '.' <<- many1 spaceChar
orderedList <- newRule $ orderedListTight // orderedListLoose
orderedListTight <- newRule $ many1 (orderedListItem ## (\s -> [Markdown s])) <<- many blankline <<-
doesNotMatch orderedListLoose ## OrderedList
orderedListLoose <- newRule $ many1 ((orderedListItem <<- many blankline) ## (\s -> [Markdown $ s ++ "\n\n"])) ##
OrderedList
- orderedListItem <- newRule $ enumerator ->>
- orderedListBlock <++> (many orderedListContinuationBlock ## concat)
- orderedListBlock <- newRule $ anyline <++> (many (doesNotMatch (optional indent ->> (bulletListItem // orderedListItem))
- ->> doesNotMatch blankline ->> doesNotMatch (indent ->> (enumerator // enumerator)) ->>
- optionallyIndentedLine) ## concat)
- orderedListContinuationBlock <- newRule $ ((many1 blankline ## concat) // unit "\0") <++>
- (many1 (indent ->> orderedListBlock) ## concat)
+ orderedListItem <- newRule $ enumerator ->> listBlock <++> (many listContinuationBlock ## concat)
let htmlBlockOpening tag = text "<" <++> spnl <++> text tag <++> spnl <++> (many htmlAttribute ## concat)

0 comments on commit 8a4f5a1

Please sign in to comment.