summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-09-14 22:38:23 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-14 22:38:23 -0700
commit64472a468c9edbe118fa31c618a75a0e5522bbec (patch)
treeda80bc73788140c90fc7b884ca62b99a14422b44
parent5849b89e52de64a5bbebbc815772ad6bbc883c1d (diff)
FromJSON/ToJSON instances for Reader, WriterOptions.
Depends on skylighting 0.3.5.
-rw-r--r--pandoc.cabal4
-rw-r--r--src/Text/Pandoc/Extensions.hs10
-rw-r--r--src/Text/Pandoc/Options.hs8
-rw-r--r--stack.pkg.yaml2
-rw-r--r--stack.yaml2
5 files changed, 22 insertions, 4 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index cdb3e92f9..18c66ed0e 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -316,7 +316,7 @@ library
tagsoup >= 0.13.7 && < 0.15,
base64-bytestring >= 0.1 && < 1.1,
zlib >= 0.5 && < 0.7,
- skylighting >= 0.3.4.1 && < 0.4,
+ skylighting >= 0.3.5 && < 0.4,
data-default >= 0.4 && < 0.8,
temporary >= 1.1 && < 1.3,
blaze-html >= 0.5 && < 0.10,
@@ -553,7 +553,7 @@ test-suite test-pandoc
filepath >= 1.1 && < 1.5,
hslua >= 0.8 && < 0.9,
process >= 1.2.3 && < 1.7,
- skylighting >= 0.3.4.1 && < 0.4,
+ skylighting >= 0.3.5 && < 0.4,
temporary >= 1.1 && < 1.3,
Diff >= 0.2 && < 0.4,
tasty >= 0.11 && < 0.12,
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 = []
diff --git a/stack.pkg.yaml b/stack.pkg.yaml
index 80ef88d84..ffa304b64 100644
--- a/stack.pkg.yaml
+++ b/stack.pkg.yaml
@@ -19,7 +19,7 @@ packages:
extra-deps:
- texmath-0.9.4.2
- hslua-0.8.0
-- skylighting-0.3.4.1
+- skylighting-0.3.5
- cmark-gfm-0.1.1
- QuickCheck-2.10.0.1
- tasty-quickcheck-0.9.1
diff --git a/stack.yaml b/stack.yaml
index 38042c5b7..eeb6f4cdb 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -9,7 +9,7 @@ packages:
extra-deps:
- texmath-0.9.4.2
- hslua-0.8.0
-- skylighting-0.3.4.1
+- skylighting-0.3.5
- cmark-gfm-0.1.1
- QuickCheck-2.10.0.1
- tasty-quickcheck-0.9.1