diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Extensions.hs | 10 | ||||
-rw-r--r-- | src/Text/Pandoc/Options.hs | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs index 95e59063b..5d3a4cb29 100644 --- a/src/Text/Pandoc/Extensions.hs +++ b/src/Text/Pandoc/Extensions.hs @@ -51,10 +51,16 @@ import Data.Typeable (Typeable) import GHC.Generics (Generic) import Text.Pandoc.Shared (safeRead) import Text.Parsec +import Data.Aeson (ToJSON(..), FromJSON(..), + genericToEncoding, defaultOptions) newtype Extensions = Extensions Integer deriving (Show, Read, Eq, Ord, Data, Typeable, Generic) +instance ToJSON Extensions where + toEncoding = genericToEncoding defaultOptions +instance FromJSON Extensions + instance Monoid Extensions where mempty = Extensions 0 mappend (Extensions a) (Extensions b) = Extensions (a .|. b) @@ -148,6 +154,10 @@ data Extension = | Ext_spaced_reference_links -- ^ Allow space between two parts of ref link deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic) +instance ToJSON Extension where + toEncoding = genericToEncoding defaultOptions +instance FromJSON Extension + -- | Extensions to be used with pandoc-flavored markdown. pandocExtensions :: Extensions pandocExtensions = extensionsFromList diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 0bd66d54d..7046e984a 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -68,6 +68,10 @@ data ReaderOptions = ReaderOptions{ , readerTrackChanges :: TrackChanges } deriving (Show, Read, Data, Typeable, Generic) +instance ToJSON ReaderOptions where + toEncoding = genericToEncoding defaultOptions +instance FromJSON ReaderOptions + instance Default ReaderOptions where def = ReaderOptions{ readerExtensions = emptyExtensions @@ -221,6 +225,10 @@ data WriterOptions = WriterOptions , writerSyntaxMap :: SyntaxMap } deriving (Show, Data, Typeable, Generic) +instance ToJSON WriterOptions where + toEncoding = genericToEncoding defaultOptions +instance FromJSON WriterOptions + instance Default WriterOptions where def = WriterOptions { writerTemplate = Nothing , writerVariables = [] |