git.iko.soy/typeable/pandoc
on master help sign in
Changed Markdown reader so that the first pass, in which a list
0b6dc98fiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+3−2
@@ -163,7 +163,8 @@ parseMarkdown = do
163 (title, author, date) <- option ([],[],"") titleBlock
163 (title, author, date) <- option ([],[],"") titleBlock
164 oldState <- getState
164 oldState <- getState
165 oldInput <- getInput
165 oldInput <- getInput
166− parseBlocks -- go through once just to get list of reference keys
166+ -- go through once just to get list of reference keys
167+ manyTill (referenceKey <|> (do{anyLine; return Null})) eof
167 newState <- getState
168 newState <- getState
168 let keysUsed = stateKeysUsed newState
169 let keysUsed = stateKeysUsed newState
169 setInput oldInput
170 setInput oldInput
@@ -492,7 +493,7 @@ rawHtmlBlocks = try (do
492--
493--
493
494
494referenceKey = try (do
495referenceKey = try (do
495− skipSpaces
496+ skipNonindentSpaces
496 label <- reference
497 label <- reference
497 char labelSep
498 char labelSep
498 skipSpaces
499 skipSpaces
src/Text/ParserCombinators/Pandoc.hs+5
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28Special parser combinators for Pandoc readers.
28Special parser combinators for Pandoc readers.
29-}
29-}
30module Text.ParserCombinators.Pandoc (
30module Text.ParserCombinators.Pandoc (
31+ anyLine,
31 many1Till,
32 many1Till,
32 followedBy',
33 followedBy',
33 notFollowedBy',
34 notFollowedBy',
@@ -47,6 +48,10 @@ import Text.Pandoc.Definition
47import Text.Pandoc.Shared
48import Text.Pandoc.Shared
48import Char ( toUpper, toLower )
49import Char ( toUpper, toLower )
49
50
51+--- | Parse any line of text
52+anyLine :: GenParser Char st [Char]
53+anyLine = manyTill anyChar (newline <|> (do{eof; return '\n'}))
54+
50-- | Parses a character and returns 'Null' (so that the parser can move on
55-- | Parses a character and returns 'Null' (so that the parser can move on
51-- if it gets stuck).
56-- if it gets stuck).
52nullBlock :: GenParser Char st Block
57nullBlock :: GenParser Char st Block