diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-19 12:38:54 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-07-19 12:38:54 -0700 |
commit | 2351f7a112f7ebc612200ef3684cc3327dec8296 (patch) | |
tree | 379f395692b741bfb9733d3802990b8838b46271 /src/Text/Pandoc | |
parent | 26748da6d4fc6912f1ef314fb01f9969d8a5fc59 (diff) |
Provide Data.Default instances for ParserState and WriterOptions.
Now you can use def (which is re-exported by Text.Pandoc) instead of
defaultParserState or defaultWriterOptions. For now, these
are still defined too, so existing code need not change.
Closes #546.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 8 | ||||
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index cac2b71ca..70a8586db 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -88,6 +88,7 @@ import Text.Pandoc.Shared import qualified Data.Map as M import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions) import Text.HTML.TagSoup.Entity ( lookupEntity ) +import Data.Default -- | Like >>, but returns the operation on the left. -- (Suggested by Tillmann Rendel on Haskell-cafe list.) @@ -658,6 +659,9 @@ data ParserState = ParserState } deriving Show +instance Default ParserState where + def = defaultParserState + defaultParserState :: ParserState defaultParserState = ParserState { stateParseRaw = False, @@ -872,13 +876,13 @@ macro = do inp <- getInput case parseMacroDefinitions inp of ([], _) -> pzero - (ms, rest) -> do def <- count (length inp - length rest) anyChar + (ms, rest) -> do def' <- count (length inp - length rest) anyChar if apply then do updateState $ \st -> st { stateMacros = ms ++ stateMacros st } return Null - else return $ RawBlock "latex" def + else return $ RawBlock "latex" def' -- | Apply current macros to string. applyMacros' :: String -> GenParser Char ParserState String diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index f14a57c1f..6c8904010 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -72,7 +72,7 @@ module Text.Pandoc.Shared ( readDataFile, -- * Error handling err, - warn, + warn ) where import Text.Pandoc.Definition @@ -94,6 +94,7 @@ import Text.Pandoc.Highlighting (Style, pygments) import Text.Pandoc.Pretty (charWidth) import System.Locale (defaultTimeLocale) import Data.Time +import Data.Default import System.IO (stderr) -- @@ -524,6 +525,9 @@ data WriterOptions = WriterOptions , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex } deriving Show +instance Default WriterOptions where + def = defaultWriterOptions + {-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-} -- | Default writer options. defaultWriterOptions :: WriterOptions |