git.iko.soy/typeable/pandoc
on master help sign in
Changed Markdown reader so that the first pass, in which a list

of reference keys is made, is much faster. This gets us a big performance boost. git-svn-id: https://pandoc.googlecode.com/svn/trunk@353 788f1e2b-df1e-0410-8736-df70ead52e1b

commit0b6dc98a0aba0e76567744c00ed6840215ca5d9d authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 31 Dec 2006, 17:34 (20 years ago) parent83cddbc
2 files changed+8−2
src/Text/Pandoc/Readers/Markdown.hs+3−2 src/Text/ParserCombinators/Pandoc.hs+5
src/Text/Pandoc/Readers/Markdown.hs+3−2
@@ -163,7 +163,8 @@ parseMarkdown = do
163163 (title, author, date) <- option ([],[],"") titleBlock
164164 oldState <- getState
165165 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
167168 newState <- getState
168169 let keysUsed = stateKeysUsed newState
169170 setInput oldInput
@@ -492,7 +493,7 @@ rawHtmlBlocks = try (do
492493--
493494
494495referenceKey = try (do
495− skipSpaces
496+ skipNonindentSpaces
496497 label <- reference
497498 char labelSep
498499 skipSpaces
src/Text/ParserCombinators/Pandoc.hs+5
@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2828Special parser combinators for Pandoc readers.
2929-}
3030module Text.ParserCombinators.Pandoc (
31+ anyLine,
3132 many1Till,
3233 followedBy',
3334 notFollowedBy',
@@ -47,6 +48,10 @@ import Text.Pandoc.Definition
4748import Text.Pandoc.Shared
4849import Char ( toUpper, toLower )
4950
51+--- | Parse any line of text
52+anyLine :: GenParser Char st [Char]
53+anyLine = manyTill anyChar (newline <|> (do{eof; return '\n'}))
54+
5055-- | Parses a character and returns 'Null' (so that the parser can move on
5156-- if it gets stuck).
5257nullBlock :: GenParser Char st Block