git.iko.soy/typeable/pandoc
on master help sign in
Moved stateApplyMacros, stateIndentedCodeClasses to ReaderOptions.
2654da3John MacFarlane
src/Text/Pandoc/Options.hs+14−9
@@ -62,17 +62,22 @@ data ReaderOptions = ReaderOptions{
62 -- - before numerial is en-dash
62 -- - before numerial is en-dash
63 , readerLiterateHaskell :: Bool -- ^ Interpret as literate Haskell
63 , readerLiterateHaskell :: Bool -- ^ Interpret as literate Haskell
64 , readerCitations :: [String] -- ^ List of available citations
64 , readerCitations :: [String] -- ^ List of available citations
65+ , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
66+ , readerIndentedCodeClasses :: [String] -- ^ Default classes for
67+ -- indented code blocks
65} deriving (Show, Read)
68} deriving (Show, Read)
66
69
67instance Default ReaderOptions
70instance Default ReaderOptions
68 where def = ReaderOptions{
71 where def = ReaderOptions{
69− readerExtensions = Set.fromList [minBound..maxBound]
72+ readerExtensions = Set.fromList [minBound..maxBound]
70− , readerSmart = False
73+ , readerSmart = False
71− , readerStrict = False
74+ , readerStrict = False
72− , readerParseRaw = False
75+ , readerParseRaw = False
73− , readerColumns = 80
76+ , readerColumns = 80
74− , readerTabStop = 4
77+ , readerTabStop = 4
75− , readerOldDashes = False
78+ , readerOldDashes = False
76− , readerLiterateHaskell = False
79+ , readerLiterateHaskell = False
77− , readerCitations = []
80+ , readerCitations = []
81+ , readerApplyMacros = True
82+ , readerIndentedCodeClasses = []
78 }
83 }
src/Text/Pandoc/Parsing.hs+2−6
@@ -698,11 +698,9 @@ data ParserState = ParserState
698 stateAuthors :: [[Inline]], -- ^ Authors of document
698 stateAuthors :: [[Inline]], -- ^ Authors of document
699 stateDate :: [Inline], -- ^ Date of document
699 stateDate :: [Inline], -- ^ Date of document
700 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
700 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
701− stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks
702 stateNextExample :: Int, -- ^ Number of next example
701 stateNextExample :: Int, -- ^ Number of next example
703 stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
702 stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
704 stateHasChapters :: Bool, -- ^ True if \chapter encountered
703 stateHasChapters :: Bool, -- ^ True if \chapter encountered
705− stateApplyMacros :: Bool, -- ^ Apply LaTeX macros?
706 stateMacros :: [Macro], -- ^ List of macros defined so far
704 stateMacros :: [Macro], -- ^ List of macros defined so far
707 stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
705 stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
708 }
706 }
@@ -724,11 +722,9 @@ defaultParserState =
724 stateAuthors = [],
722 stateAuthors = [],
725 stateDate = [],
723 stateDate = [],
726 stateHeaderTable = [],
724 stateHeaderTable = [],
727− stateIndentedCodeClasses = [],
728 stateNextExample = 1,
725 stateNextExample = 1,
729 stateExamples = M.empty,
726 stateExamples = M.empty,
730 stateHasChapters = False,
727 stateHasChapters = False,
731− stateApplyMacros = True,
732 stateMacros = [],
728 stateMacros = [],
733 stateRstDefaultRole = "title-reference"}
729 stateRstDefaultRole = "title-reference"}
734
730
@@ -916,7 +912,7 @@ emDashOld = do
916-- | Parse a \newcommand or \renewcommand macro definition.
912-- | Parse a \newcommand or \renewcommand macro definition.
917macro :: Parsec [Char] ParserState Block
913macro :: Parsec [Char] ParserState Block
918macro = do
914macro = do
919− apply <- stateApplyMacros `fmap` getState
915+ apply <- getOption readerApplyMacros
920 inp <- getInput
916 inp <- getInput
921 case parseMacroDefinitions inp of
917 case parseMacroDefinitions inp of
922 ([], _) -> mzero
918 ([], _) -> mzero
@@ -931,7 +927,7 @@ macro = do
931-- | Apply current macros to string.
927-- | Apply current macros to string.
932applyMacros' :: String -> Parsec [Char] ParserState String
928applyMacros' :: String -> Parsec [Char] ParserState String
933applyMacros' target = do
929applyMacros' target = do
934− apply <- liftM stateApplyMacros getState
930+ apply <- getOption readerApplyMacros
935 if apply
931 if apply
936 then do macros <- liftM stateMacros getState
932 then do macros <- liftM stateMacros getState
937 return $ applyMacros macros target
933 return $ applyMacros macros target
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -444,8 +444,8 @@ codeBlockIndented = do
444 l <- indentedLine
444 l <- indentedLine
445 return $ b ++ l))
445 return $ b ++ l))
446 optional blanklines
446 optional blanklines
447− st <- getState
447+ classes <- getOption readerIndentedCodeClasses
448− return $ CodeBlock ("", stateIndentedCodeClasses st, []) $
448+ return $ CodeBlock ("", classes, []) $
449 stripTrailingNewlines $ concat contents
449 stripTrailingNewlines $ concat contents
450
450
451lhsCodeBlock :: Parser [Char] ParserState Block
451lhsCodeBlock :: Parser [Char] ParserState Block
src/pandoc.hs+3−3
@@ -948,9 +948,9 @@ main = do
948 "+lhs" `isSuffixOf` readerName' ||
948 "+lhs" `isSuffixOf` readerName' ||
949 lhsExtension sources
949 lhsExtension sources
950 , readerCitations = map CSL.refId refs
950 , readerCitations = map CSL.refId refs
951− },
951+ , readerIndentedCodeClasses = codeBlockClasses
952− stateIndentedCodeClasses = codeBlockClasses,
953− stateApplyMacros = not laTeXOutput
952+ , readerApplyMacros = not laTeXOutput
953+ }
954 }
954 }
955
955
956 let writerOptions = def { writerStandalone = standalone',
956 let writerOptions = def { writerStandalone = standalone',