git.iko.soy/typeable/pandoc
on master help sign in
Moved stateApplyMacros, stateIndentedCodeClasses to ReaderOptions.
commit2654da38237a981777ed57e4af64781e3773bf01 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 25 Jul 2012, 20:42 (14 years ago) parent070b968
4 files changed+21−20
src/Text/Pandoc/Options.hs+14−9 src/Text/Pandoc/Parsing.hs+2−6 src/Text/Pandoc/Readers/Markdown.hs+2−2 src/pandoc.hs+3−3
src/Text/Pandoc/Options.hs+14−9
@@ -62,17 +62,22 @@ data ReaderOptions = ReaderOptions{
6262 -- - before numerial is en-dash
6363 , readerLiterateHaskell :: Bool -- ^ Interpret as literate Haskell
6464 , readerCitations :: [String] -- ^ List of available citations
65+ , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
66+ , readerIndentedCodeClasses :: [String] -- ^ Default classes for
67+ -- indented code blocks
6568} deriving (Show, Read)
6669
6770instance Default ReaderOptions
6871 where def = ReaderOptions{
69− readerExtensions = Set.fromList [minBound..maxBound]
70− , readerSmart = False
71− , readerStrict = False
72− , readerParseRaw = False
73− , readerColumns = 80
74− , readerTabStop = 4
75− , readerOldDashes = False
76− , readerLiterateHaskell = False
77− , readerCitations = []
72+ readerExtensions = Set.fromList [minBound..maxBound]
73+ , readerSmart = False
74+ , readerStrict = False
75+ , readerParseRaw = False
76+ , readerColumns = 80
77+ , readerTabStop = 4
78+ , readerOldDashes = False
79+ , readerLiterateHaskell = False
80+ , readerCitations = []
81+ , readerApplyMacros = True
82+ , readerIndentedCodeClasses = []
7883 }
src/Text/Pandoc/Parsing.hs+2−6
@@ -698,11 +698,9 @@ data ParserState = ParserState
698698 stateAuthors :: [[Inline]], -- ^ Authors of document
699699 stateDate :: [Inline], -- ^ Date of document
700700 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
701− stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks
702701 stateNextExample :: Int, -- ^ Number of next example
703702 stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
704703 stateHasChapters :: Bool, -- ^ True if \chapter encountered
705− stateApplyMacros :: Bool, -- ^ Apply LaTeX macros?
706704 stateMacros :: [Macro], -- ^ List of macros defined so far
707705 stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
708706 }
@@ -724,11 +722,9 @@ defaultParserState =
724722 stateAuthors = [],
725723 stateDate = [],
726724 stateHeaderTable = [],
727− stateIndentedCodeClasses = [],
728725 stateNextExample = 1,
729726 stateExamples = M.empty,
730727 stateHasChapters = False,
731− stateApplyMacros = True,
732728 stateMacros = [],
733729 stateRstDefaultRole = "title-reference"}
734730
@@ -916,7 +912,7 @@ emDashOld = do
916912-- | Parse a \newcommand or \renewcommand macro definition.
917913macro :: Parsec [Char] ParserState Block
918914macro = do
919− apply <- stateApplyMacros `fmap` getState
915+ apply <- getOption readerApplyMacros
920916 inp <- getInput
921917 case parseMacroDefinitions inp of
922918 ([], _) -> mzero
@@ -931,7 +927,7 @@ macro = do
931927-- | Apply current macros to string.
932928applyMacros' :: String -> Parsec [Char] ParserState String
933929applyMacros' target = do
934− apply <- liftM stateApplyMacros getState
930+ apply <- getOption readerApplyMacros
935931 if apply
936932 then do macros <- liftM stateMacros getState
937933 return $ applyMacros macros target
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -444,8 +444,8 @@ codeBlockIndented = do
444444 l <- indentedLine
445445 return $ b ++ l))
446446 optional blanklines
447− st <- getState
448− return $ CodeBlock ("", stateIndentedCodeClasses st, []) $
447+ classes <- getOption readerIndentedCodeClasses
448+ return $ CodeBlock ("", classes, []) $
449449 stripTrailingNewlines $ concat contents
450450
451451lhsCodeBlock :: Parser [Char] ParserState Block
src/pandoc.hs+3−3
@@ -948,9 +948,9 @@ main = do
948948 "+lhs" `isSuffixOf` readerName' ||
949949 lhsExtension sources
950950 , readerCitations = map CSL.refId refs
951− },
952− stateIndentedCodeClasses = codeBlockClasses,
953− stateApplyMacros = not laTeXOutput
951+ , readerIndentedCodeClasses = codeBlockClasses
952+ , readerApplyMacros = not laTeXOutput
953+ }
954954 }
955955
956956 let writerOptions = def { writerStandalone = standalone',