From 05216d29198618d7490cc5008ff263dfa60475c0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 9 Aug 2012 20:41:50 -0700 Subject: Fixed handling of default extensions, so they don't override +options. --- src/Text/Pandoc.hs | 18 ++++++++++-------- 1 file 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 -- cgit v1.2.3