aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-08-09 20:41:50 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-08-09 20:41:50 -0700
commit05216d29198618d7490cc5008ff263dfa60475c0 (patch)
tree3a37273264e8f8d0931ec9d471f3e0ba827be1f9
parent0cb7362f62410f58e2356381bbf2c1fe85abe2a5 (diff)
downloadpandoc-05216d29198618d7490cc5008ff263dfa60475c0.tar.gz
Fixed handling of default extensions, so they don't override +options.
-rw-r--r--src/Text/Pandoc.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index 61e461b35..b43eaede2 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -176,8 +176,7 @@ parseFormatSpec = parse formatSpec ""
readers :: [(String, ReaderOptions -> String -> Pandoc)]
readers = [("native" , \_ -> readNative)
,("json" , \_ -> decodeJSON)
- ,("strict" , \o -> readMarkdown
- o{ readerExtensions = strictExtensions } )
+ ,("strict" , readMarkdown)
,("markdown" , readMarkdown)
,("rst" , readRST)
,("docbook" , readDocBook)
@@ -221,8 +220,7 @@ writers = [
,("texinfo" , PureStringWriter writeTexinfo)
,("man" , PureStringWriter writeMan)
,("markdown" , PureStringWriter writeMarkdown)
- ,("strict" , PureStringWriter $ \o ->
- writeMarkdown o{ writerExtensions = strictExtensions } )
+ ,("strict" , PureStringWriter writeMarkdown)
,("plain" , PureStringWriter writePlain)
,("rst" , PureStringWriter writeRST)
,("mediawiki" , PureStringWriter writeMediaWiki)
@@ -232,6 +230,10 @@ writers = [
,("asciidoc" , PureStringWriter writeAsciiDoc)
]
+getDefaultExtensions :: String -> Set Extension
+getDefaultExtensions "strict" = strictExtensions
+getDefaultExtensions _ = pandocExtensions
+
-- | Retrieve reader based on formatSpec (format+extensions).
getReader :: String -> Either String (ReaderOptions -> String -> Pandoc)
getReader s =
@@ -242,7 +244,7 @@ getReader s =
Nothing -> Left $ "Unknown reader: " ++ readerName
Just r -> Right $ \o ->
r o{ readerExtensions = setExts $
- readerExtensions o }
+ getDefaultExtensions readerName }
-- | Retrieve writer based on formatSpec (format+extensions).
getWriter :: String -> Either String Writer
@@ -254,13 +256,13 @@ getWriter s =
Nothing -> Left $ "Unknown writer: " ++ writerName
Just (PureStringWriter r) -> Right $ PureStringWriter $
\o -> r o{ writerExtensions = setExts $
- writerExtensions o }
+ getDefaultExtensions writerName }
Just (IOStringWriter r) -> Right $ IOStringWriter $
\o -> r o{ writerExtensions = setExts $
- writerExtensions o }
+ getDefaultExtensions writerName }
Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $
\o -> r o{ writerExtensions = setExts $
- writerExtensions o }
+ getDefaultExtensions writerName }
{-# DEPRECATED jsonFilter "Use toJsonFilter instead" #-}
-- | Converts a transformation on the Pandoc AST into a function