diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Tests/Readers/Markdown.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc.hs | 12 | ||||
-rw-r--r-- | src/Text/Pandoc/Options.hs | 30 | ||||
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 4 | ||||
-rw-r--r-- | src/pandoc.hs | 7 |
5 files changed, 32 insertions, 24 deletions
diff --git a/src/Tests/Readers/Markdown.hs b/src/Tests/Readers/Markdown.hs index e6612f475..ca7dc457b 100644 --- a/src/Tests/Readers/Markdown.hs +++ b/src/Tests/Readers/Markdown.hs @@ -93,7 +93,8 @@ tests = [ testGroup "inline code" =?> para (note (para "See [^1]")) ] , testGroup "lhs" - [ test (readMarkdown defaultParserState{stateLiterateHaskell = True}) + [ test (readMarkdown def{stateOptions = + def{readerLiterateHaskell = True}}) "inverse bird tracks and html" $ "> a\n\n< b\n\n<div>\n" =?> codeBlockWith ("",["sourceCode","literate","haskell"],[]) "a" diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 193755dff..95fec7360 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -170,16 +170,22 @@ readers = [("native" , \_ -> readNative) ,("json" , \_ -> decodeJSON) ,("markdown" , readMarkdown) ,("markdown+lhs" , \st -> - readMarkdown st{ stateLiterateHaskell = True}) + readMarkdown st{ stateOptions = + let oldopts = stateOptions st + in oldopts{ readerLiterateHaskell = True} }) ,("rst" , readRST) ,("rst+lhs" , \st -> - readRST st{ stateLiterateHaskell = True}) + readRST st{ stateOptions = + let oldopts = stateOptions st + in oldopts{ readerLiterateHaskell = True} }) ,("docbook" , readDocBook) ,("textile" , readTextile) -- TODO : textile+lhs ,("html" , readHtml) ,("latex" , readLaTeX) ,("latex+lhs" , \st -> - readLaTeX st{ stateLiterateHaskell = True}) + readLaTeX st{ stateOptions = + let oldopts = stateOptions st + in oldopts{ readerLiterateHaskell = True} }) ] data Writer = PureStringWriter (WriterOptions -> Pandoc -> String) diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index bd04a4373..063162718 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -51,24 +51,26 @@ data Extension = Footnotes deriving (Show, Read, Enum, Eq, Ord, Bounded) data ReaderOptions = ReaderOptions{ - readerExtensions :: Set Extension -- ^ Syntax extensions - , readerSmart :: Bool -- ^ Smart punctuation - , readerStrict :: Bool -- ^ FOR TRANSITION ONLY - , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX - , readerColumns :: Int -- ^ Number of columns in terminal - , readerTabStop :: Int -- ^ Tab stop - , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior + readerExtensions :: Set Extension -- ^ Syntax extensions + , readerSmart :: Bool -- ^ Smart punctuation + , readerStrict :: Bool -- ^ FOR TRANSITION ONLY + , readerParseRaw :: Bool -- ^ Parse raw HTML, LaTeX + , readerColumns :: Int -- ^ Number of columns in terminal + , readerTabStop :: Int -- ^ Tab stop + , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior -- in parsing dashes; -- is em-dash; -- - before numerial is en-dash + , readerLiterateHaskell :: Bool -- ^ Interpret as literate Haskell } deriving (Show, Read) instance Default ReaderOptions where def = ReaderOptions{ - readerExtensions = Set.fromList [minBound..maxBound] - , readerSmart = False - , readerStrict = False - , readerParseRaw = False - , readerColumns = 80 - , readerTabStop = 4 - , readerOldDashes = False + readerExtensions = Set.fromList [minBound..maxBound] + , readerSmart = False + , readerStrict = False + , readerParseRaw = False + , readerColumns = 80 + , readerTabStop = 4 + , readerOldDashes = False + , readerLiterateHaskell = False } diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 9c553a9ed..a266c527e 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -395,7 +395,7 @@ failIfStrict = getOption readerStrict >>= guard . not -- | Fail unless we're in literate haskell mode. failUnlessLHS :: Parsec [tok] ParserState () -failUnlessLHS = getState >>= guard . stateLiterateHaskell +failUnlessLHS = getOption readerLiterateHaskell >>= guard -- | Parses backslash, then applies character parser. escaped :: Parsec [Char] st Char -- ^ Parser for character to escape @@ -698,7 +698,6 @@ data ParserState = ParserState stateTitle :: [Inline], -- ^ Title of document stateAuthors :: [[Inline]], -- ^ Authors of document stateDate :: [Inline], -- ^ Date of document - stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks stateNextExample :: Int, -- ^ Number of next example @@ -726,7 +725,6 @@ defaultParserState = stateTitle = [], stateAuthors = [], stateDate = [], - stateLiterateHaskell = False, stateHeaderTable = [], stateIndentedCodeClasses = [], stateNextExample = 1, diff --git a/src/pandoc.hs b/src/pandoc.hs index ba8c19dad..884e851f9 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -936,9 +936,7 @@ main = do then "." else takeDirectory (head sources) - let startParserState = def{ stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' || - lhsExtension sources, - stateCitations = map CSL.refId refs, + let startParserState = def{ stateCitations = map CSL.refId refs, stateOptions = def{ readerStrict = strict , readerSmart = smart || (texLigatures && @@ -947,6 +945,9 @@ main = do , readerColumns = columns , readerTabStop = tabStop , readerOldDashes = oldDashes + , readerLiterateHaskell = + "+lhs" `isSuffixOf` readerName' || + lhsExtension sources }, stateIndentedCodeClasses = codeBlockClasses, stateApplyMacros = not laTeXOutput |