git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc.App.Opt: more convenient To/FromJSON instances.

Make the field names like `strip-empty-paragraphs` rather than `optStripEmptyParagraphs`.

commit2e35eafd12f062529cfb352f213f0a09fd26f11e authorJohn MacFarlane <jgm@berkeley.edu> dateSun 6 Oct 2019, 16:24 (7 years ago) parent175c57a
1 file changed+9−5
src/Text/Pandoc/App/Opt.hs+9−5
src/Text/Pandoc/App/Opt.hs+9−5
@@ -31,11 +31,11 @@ import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault),
3131 ReferenceLocation (EndOfDocument),
3232 ObfuscationMethod (NoObfuscation),
3333 CiteMethod (Citeproc))
34−
34+import Text.Pandoc.Shared (camelCaseToHyphenated)
3535#ifdef DERIVE_JSON_VIA_TH
36−import Data.Aeson.TH (deriveJSON, defaultOptions)
36+import Data.Aeson.TH (deriveJSON, defaultOptions, Options(..))
3737#else
38−import Data.Aeson (FromJSON (..), ToJSON (..),
38+import Data.Aeson (FromJSON (..), ToJSON (..), Options(..)
3939 defaultOptions, genericToEncoding)
4040#endif
4141
@@ -195,13 +195,17 @@ defaultOpts = Opt
195195-- see https://github.com/jgm/pandoc/pull/4083
196196-- using generic deriving caused long compilation times
197197$(deriveJSON defaultOptions ''LineEnding)
198−$(deriveJSON defaultOptions ''Opt)
198+$(deriveJSON
199+ defaultOptions{ fieldLabelModifier =
200+ camelCaseToHyphenated . drop 3 } ''Opt)
199201#else
200202instance ToJSON LineEnding where
201203 toEncoding = genericToEncoding defaultOptions
202204instance FromJSON LineEnding
203205
204206instance ToJSON Opt where
205− toEncoding = genericToEncoding defaultOptions
207+ toEncoding = genericToEncoding
208+ defaultOptions{ fieldLabelModifier =
209+ camelCaseToHyphenated . drop 3 }
206210instance FromJSON Opt
207211#endif