diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-05-08 10:03:02 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-05-08 10:29:40 -0700 |
commit | b5bda7569e700ff45582fe2d11993776451fd6fc (patch) | |
tree | 5b0aacc2382e66244ee6062623a8028a4c686454 /src/Text/Pandoc/Readers/Markdown.hs | |
parent | 91f52e2229b6bd467eeeced96d3fff395786b2a1 (diff) | |
download | pandoc-b5bda7569e700ff45582fe2d11993776451fd6fc.tar.gz |
Made KeyTable a map instead of an association list.
* This affects the RST and Markdown readers.
* The type for stateKeys in ParserState has also changed.
* Pandoc, Meta, Inline, and Block have been given Ord instances.
* Reference keys now have a type of their own (Key), with its
own Ord instance for case-insensitive comparison.
Diffstat (limited to 'src/Text/Pandoc/Readers/Markdown.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index bc8e7cd43..a6d383fca 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Markdown ( ) where import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate ) +import qualified Data.Map as M import Data.Ord ( comparing ) import Data.Char ( isAlphaNum ) import Data.Maybe @@ -202,10 +203,10 @@ referenceKey = try $ do tit <- option "" referenceTitle blanklines endPos <- getPosition - let newkey = (lab, (escapeURI $ removeTrailingSpace src, tit)) + let target = (escapeURI $ removeTrailingSpace src, tit) st <- getState let oldkeys = stateKeys st - updateState $ \s -> s { stateKeys = newkey : oldkeys } + updateState $ \s -> s { stateKeys = M.insert (Key lab) target oldkeys } -- return blanks so line count isn't affected return $ replicate (sourceLine endPos - sourceLine startPos) '\n' @@ -1216,7 +1217,7 @@ referenceLink lab = do optional (newline >> skipSpaces) >> reference)) let ref' = if null ref then lab else ref state <- getState - case lookupKeySrc (stateKeys state) ref' of + case lookupKeySrc (stateKeys state) (Key ref') of Nothing -> fail "no corresponding key" Just target -> return target @@ -1301,7 +1302,7 @@ inlineCitation = try $ do chkCit :: Target -> GenParser Char ParserState (Maybe Target) chkCit t = do st <- getState - case lookupKeySrc (stateKeys st) [Str $ fst t] of + case lookupKeySrc (stateKeys st) (Key [Str $ fst t]) of Just _ -> fail "This is a link" Nothing -> if elem (fst t) $ stateCitations st then return $ Just t |