From 2e35eafd12f062529cfb352f213f0a09fd26f11e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 6 Oct 2019 16:24:23 -0700 Subject: Text.Pandoc.App.Opt: more convenient To/FromJSON instances. Make the field names like `strip-empty-paragraphs` rather than `optStripEmptyParagraphs`. --- src/Text/Pandoc/App/Opt.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') 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 -- cgit v1.2.3