@@ -71,13 +71,8 @@ module Text.Pandoc.Parsing ( (>>~),
71 NoteTable,
71 NoteTable,
72 NoteTable',
72 NoteTable',
81 smartPunctuation,
76 smartPunctuation,
82 withQuoteContext,
77 withQuoteContext,
83 singleQuoteStart,
78 singleQuoteStart,
@@ -145,7 +140,6 @@ where
146import Text.Pandoc.Definition
141import Text.Pandoc.Definition
147import Text.Pandoc.Options
142import Text.Pandoc.Options
148−import Text.Pandoc.Generic
149import Text.Pandoc.Builder (Blocks)
143import Text.Pandoc.Builder (Blocks)
150import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
144import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
151import Text.Parsec
145import Text.Parsec
@@ -706,8 +700,7 @@ data ParserState = ParserState
706 stateAllowLinks :: Bool, -- ^ Allow parsing of links
700 stateAllowLinks :: Bool, -- ^ Allow parsing of links
707 stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph
701 stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph
708 stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed
702 stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed
709− stateKeys :: KeyTable, -- ^ List of reference keys
703+ stateKeys :: KeyTable, -- ^ List of reference keys (with fallbacks)
710− stateKeys' :: KeyTable', -- ^ List of reference keys (with fallbacks)
711 stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
704 stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
712 stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
705 stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
713 stateTitle :: [Inline], -- ^ Title of document
706 stateTitle :: [Inline], -- ^ Title of document
@@ -733,7 +726,6 @@ defaultParserState =
733 stateMaxNestingLevel = 6,
726 stateMaxNestingLevel = 6,
734 stateLastStrPos = Nothing,
727 stateLastStrPos = Nothing,
735 stateKeys = M.empty,
728 stateKeys = M.empty,
736− stateKeys' = M.empty,
737 stateNotes = [],
729 stateNotes = [],
738 stateNotes' = [],
730 stateNotes' = [],
739 stateTitle = [],
731 stateTitle = [],
@@ -777,38 +769,13 @@ type NoteTable = [(String, String)]
778type NoteTable' = [(String, Reader ParserState Blocks)] -- used in markdown reader
770type NoteTable' = [(String, Reader ParserState Blocks)] -- used in markdown reader
780−newtype Key = Key [Inline] deriving (Show, Read, Eq, Ord)
772+newtype Key = Key String deriving (Show, Read, Eq, Ord)
782−toKey :: [Inline] -> Key
774+toKey :: String -> Key
783−toKey = Key . bottomUp lowercase
775+toKey = Key . map toLower . unwords . words
784− where lowercase :: Inline -> Inline
785− lowercase (Str xs) = Str (map toLower xs)
786− lowercase (Math t xs) = Math t (map toLower xs)
787− lowercase (Code attr xs) = Code attr (map toLower xs)
788− lowercase (RawInline f xs) = RawInline f (map toLower xs)
789− lowercase LineBreak = Space
792−fromKey :: Key -> [Inline]
793−fromKey (Key xs) = xs
795type KeyTable = M.Map Key Target
777type KeyTable = M.Map Key Target
797−newtype Key' = Key' String deriving (Show, Read, Eq, Ord)
799−toKey' :: String -> Key'
800−toKey' = Key' . map toLower . unwords . words
802−type KeyTable' = M.Map Key' Target
804−-- | Look up key in key table and return target object.
805−lookupKeySrc :: KeyTable -- ^ Key table
808−lookupKeySrc table key = case M.lookup key table of
810− Just src -> Just src
812-- | Fail unless we're in "smart typography" mode.
779-- | Fail unless we're in "smart typography" mode.
813failUnlessSmart :: Parser [tok] ParserState ()
780failUnlessSmart :: Parser [tok] ParserState ()
814failUnlessSmart = getOption readerSmart >>= guard
781failUnlessSmart = getOption readerSmart >>= guard