diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-10-06 16:24:23 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-10-06 16:25:05 -0700 |
commit | 2e35eafd12f062529cfb352f213f0a09fd26f11e (patch) | |
tree | 7b72090dd6aa8b2fe4d75b8f5ab1a4aff5470b43 /src/Text/Pandoc | |
parent | 175c57a966223490a7d195a8bdd37cac06f18110 (diff) | |
download | pandoc-2e35eafd12f062529cfb352f213f0a09fd26f11e.tar.gz |
Text.Pandoc.App.Opt: more convenient To/FromJSON instances.
Make the field names like `strip-empty-paragraphs` rather
than `optStripEmptyParagraphs`.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/App/Opt.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs index 1111a5457..86ef60d2b 100644 --- a/src/Text/Pandoc/App/Opt.hs +++ b/src/Text/Pandoc/App/Opt.hs @@ -31,11 +31,11 @@ import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault), ReferenceLocation (EndOfDocument), ObfuscationMethod (NoObfuscation), CiteMethod (Citeproc)) - +import Text.Pandoc.Shared (camelCaseToHyphenated) #ifdef DERIVE_JSON_VIA_TH -import Data.Aeson.TH (deriveJSON, defaultOptions) +import Data.Aeson.TH (deriveJSON, defaultOptions, Options(..)) #else -import Data.Aeson (FromJSON (..), ToJSON (..), +import Data.Aeson (FromJSON (..), ToJSON (..), Options(..) defaultOptions, genericToEncoding) #endif @@ -195,13 +195,17 @@ defaultOpts = Opt -- see https://github.com/jgm/pandoc/pull/4083 -- using generic deriving caused long compilation times $(deriveJSON defaultOptions ''LineEnding) -$(deriveJSON defaultOptions ''Opt) +$(deriveJSON + defaultOptions{ fieldLabelModifier = + camelCaseToHyphenated . drop 3 } ''Opt) #else instance ToJSON LineEnding where toEncoding = genericToEncoding defaultOptions instance FromJSON LineEnding instance ToJSON Opt where - toEncoding = genericToEncoding defaultOptions + toEncoding = genericToEncoding + defaultOptions{ fieldLabelModifier = + camelCaseToHyphenated . drop 3 } instance FromJSON Opt #endif |