git.iko.soy/typeable/pandoc
on master help sign in
Provide Data.Default instances for ParserState and WriterOptions.
2351f7aJohn MacFarlane
pandoc.cabal+3
@@ -223,6 +223,7 @@ Library
223 base64-bytestring >= 0.1 && < 0.2,
223 base64-bytestring >= 0.1 && < 0.2,
224 zlib >= 0.5 && < 0.6,
224 zlib >= 0.5 && < 0.6,
225 highlighting-kate >= 0.5.1 && < 0.6,
225 highlighting-kate >= 0.5.1 && < 0.6,
226+ data-default >= 0.4 && < 0.6,
226 temporary >= 1.1 && < 1.2
227 temporary >= 1.1 && < 1.2
227 if flag(blaze_html_0_5)
228 if flag(blaze_html_0_5)
228 build-depends:
229 build-depends:
@@ -331,6 +332,7 @@ Executable pandoc
331 base64-bytestring >= 0.1 && < 0.2,
332 base64-bytestring >= 0.1 && < 0.2,
332 zlib >= 0.5 && < 0.6,
333 zlib >= 0.5 && < 0.6,
333 highlighting-kate >= 0.5.1 && < 0.6,
334 highlighting-kate >= 0.5.1 && < 0.6,
335+ data-default >= 0.4 && < 0.6,
334 temporary >= 1.1 && < 1.2
336 temporary >= 1.1 && < 1.2
335 if flag(blaze_html_0_5)
337 if flag(blaze_html_0_5)
336 build-depends:
338 build-depends:
@@ -398,6 +400,7 @@ Executable test-pandoc
398 base64-bytestring >= 0.1 && < 0.2,
400 base64-bytestring >= 0.1 && < 0.2,
399 zlib >= 0.5 && < 0.6,
401 zlib >= 0.5 && < 0.6,
400 highlighting-kate >= 0.5.1 && < 0.6,
402 highlighting-kate >= 0.5.1 && < 0.6,
403+ data-default >= 0.4 && < 0.6,
401 temporary >= 1.1 && < 1.2
404 temporary >= 1.1 && < 1.2
402 if flag(blaze_html_0_5)
405 if flag(blaze_html_0_5)
403 build-depends:
406 build-depends:
src/Text/Pandoc.hs+3
@@ -114,6 +114,8 @@ module Text.Pandoc
114 , rtfEmbedImage
114 , rtfEmbedImage
115 , jsonFilter
115 , jsonFilter
116 , ToJsonFilter(..)
116 , ToJsonFilter(..)
117+ -- * From Data.Default
118+ , def
117 ) where
119 ) where
118
120
119import Text.Pandoc.Definition
121import Text.Pandoc.Definition
@@ -149,6 +151,7 @@ import Text.Pandoc.Shared
149import Data.Version (showVersion)
151import Data.Version (showVersion)
150import Text.JSON.Generic
152import Text.JSON.Generic
151import Paths_pandoc (version)
153import Paths_pandoc (version)
154+import Data.Default
152
155
153-- | Version number of pandoc library.
156-- | Version number of pandoc library.
154pandocVersion :: String
157pandocVersion :: String
src/Text/Pandoc/Parsing.hs+6−2
@@ -88,6 +88,7 @@ import Text.Pandoc.Shared
88import qualified Data.Map as M
88import qualified Data.Map as M
89import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
89import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
90import Text.HTML.TagSoup.Entity ( lookupEntity )
90import Text.HTML.TagSoup.Entity ( lookupEntity )
91+import Data.Default
91
92
92-- | Like >>, but returns the operation on the left.
93-- | Like >>, but returns the operation on the left.
93-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
94-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
@@ -658,6 +659,9 @@ data ParserState = ParserState
658 }
659 }
659 deriving Show
660 deriving Show
660
661
662+instance Default ParserState where
663+ def = defaultParserState
664+
661defaultParserState :: ParserState
665defaultParserState :: ParserState
662defaultParserState =
666defaultParserState =
663 ParserState { stateParseRaw = False,
667 ParserState { stateParseRaw = False,
@@ -872,13 +876,13 @@ macro = do
872 inp <- getInput
876 inp <- getInput
873 case parseMacroDefinitions inp of
877 case parseMacroDefinitions inp of
874 ([], _) -> pzero
878 ([], _) -> pzero
875− (ms, rest) -> do def <- count (length inp - length rest) anyChar
879+ (ms, rest) -> do def' <- count (length inp - length rest) anyChar
876 if apply
880 if apply
877 then do
881 then do
878 updateState $ \st ->
882 updateState $ \st ->
879 st { stateMacros = ms ++ stateMacros st }
883 st { stateMacros = ms ++ stateMacros st }
880 return Null
884 return Null
881− else return $ RawBlock "latex" def
885+ else return $ RawBlock "latex" def'
882
886
883-- | Apply current macros to string.
887-- | Apply current macros to string.
884applyMacros' :: String -> GenParser Char ParserState String
888applyMacros' :: String -> GenParser Char ParserState String
src/Text/Pandoc/Shared.hs+5−1
@@ -72,7 +72,7 @@ module Text.Pandoc.Shared (
72 readDataFile,
72 readDataFile,
73 -- * Error handling
73 -- * Error handling
74 err,
74 err,
75− warn,
75+ warn
76 ) where
76 ) where
77
77
78import Text.Pandoc.Definition
78import Text.Pandoc.Definition
@@ -94,6 +94,7 @@ import Text.Pandoc.Highlighting (Style, pygments)
94import Text.Pandoc.Pretty (charWidth)
94import Text.Pandoc.Pretty (charWidth)
95import System.Locale (defaultTimeLocale)
95import System.Locale (defaultTimeLocale)
96import Data.Time
96import Data.Time
97+import Data.Default
97import System.IO (stderr)
98import System.IO (stderr)
98
99
99--
100--
@@ -524,6 +525,9 @@ data WriterOptions = WriterOptions
524 , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex
525 , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex
525 } deriving Show
526 } deriving Show
526
527
528+instance Default WriterOptions where
529+ def = defaultWriterOptions
530+
527{-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-}
531{-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-}
528-- | Default writer options.
532-- | Default writer options.
529defaultWriterOptions :: WriterOptions
533defaultWriterOptions :: WriterOptions