diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-06 18:41:01 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-01-06 18:41:01 +0000 |
commit | 1645fb65e4a486de95f5375bcc029a139d4d8c45 (patch) | |
tree | ed7fcc3e9634f9586c5b9da8acfdd0a0fc116e47 /src/Text/Pandoc/Shared.hs | |
parent | bb8478e4e24b431ca81ee7f669d517eb11a47500 (diff) | |
download | pandoc-1645fb65e4a486de95f5375bcc029a139d4d8c45.tar.gz |
Fixed serious performance problems with new Markdown reader:
Instead of using lookahead to determine whether a single quote
is an apostrophe, we now use state. Inside single quotes,
a ' character won't be recognized as the beginning of a single
quote. 'stateQuoteContext' has been added to keep track of
this.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@437 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 91b44e6bf..624f573de 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -47,6 +47,7 @@ module Text.Pandoc.Shared ( testStringWith, HeaderType (..), ParserContext (..), + QuoteContext (..), ParserState (..), defaultParserState, -- * Native format prettyprinting @@ -108,10 +109,17 @@ data ParserContext | NullState -- ^ Default state deriving (Eq, Show) +data QuoteContext + = InSingleQuote -- ^ Used when we're parsing inside single quotes + | InDoubleQuote -- ^ Used when we're parsing inside double quotes + | NoQuote -- ^ Used when we're not parsing inside quotes + deriving (Eq, Show) + data ParserState = ParserState { stateParseRaw :: Bool, -- ^ Parse untranslatable HTML -- and LaTeX? stateParserContext :: ParserContext, -- ^ What are we parsing? + stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment? stateKeyBlocks :: [Block], -- ^ List of reference key blocks stateKeysUsed :: [[Inline]], -- ^ List of references used stateNoteBlocks :: [Block], -- ^ List of note blocks @@ -134,6 +142,7 @@ defaultParserState :: ParserState defaultParserState = ParserState { stateParseRaw = False, stateParserContext = NullState, + stateQuoteContext = NoQuote, stateKeyBlocks = [], stateKeysUsed = [], stateNoteBlocks = [], |