From 952a7dac589107cc19e606ff9cf29dfbb33002bc Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 2 Jun 2016 22:17:46 +0200 Subject: Org reader: support smart quotes export option Reading of smart quotes can be toggled using the `'` option. --- src/Text/Pandoc/Readers/Org/ParserState.hs | 31 +++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Readers/Org/ParserState.hs') diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index cadc9bfb7..d566346e8 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -42,9 +42,11 @@ module Text.Pandoc.Readers.Org.ParserState , returnF , ExportSettingSetter , ExportSettings (..) - , setExportSubSuperscripts , setExportDrawers + , setExportSmartQuotes + , setExportSubSuperscripts , modifyExportSettings + , optionsToParserState ) where import Control.Monad (liftM, liftM2) @@ -77,11 +79,12 @@ type OrgLinkFormatters = M.Map String (String -> String) -- | Export settings -- These settings can be changed via OPTIONS statements. data ExportSettings = ExportSettings - { exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts - , exportDrawers :: Either [String] [String] + { exportDrawers :: Either [String] [String] -- ^ Specify drawer names which should be exported. @Left@ names are -- explicitly excluded from the resulting output while @Right@ means that -- only the listed drawer names should be included. + , exportSmartQuotes :: Bool -- ^ Parse quotes, ellipses, apostrophs smartly + , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts } -- | Org-mode parser state @@ -152,25 +155,35 @@ defaultOrgParserState = OrgParserState defaultExportSettings :: ExportSettings defaultExportSettings = ExportSettings - { exportSubSuperscripts = True - , exportDrawers = Left ["LOGBOOK"] + { exportDrawers = Left ["LOGBOOK"] + , exportSmartQuotes = True + , exportSubSuperscripts = True } +optionsToParserState :: ReaderOptions -> OrgParserState +optionsToParserState opts = + def { orgStateOptions = opts } + -- -- Setter for exporting options -- type ExportSettingSetter a = a -> ExportSettings -> ExportSettings +-- | Set export options for drawers. See the @exportDrawers@ in ADT +-- @ExportSettings@ for details. +setExportDrawers :: ExportSettingSetter (Either [String] [String]) +setExportDrawers val es = es { exportDrawers = val } + -- | Set export options for sub/superscript parsing. The short syntax will -- not be parsed if this is set set to @False@. setExportSubSuperscripts :: ExportSettingSetter Bool setExportSubSuperscripts val es = es { exportSubSuperscripts = val } --- | Set export options for drawers. See the @exportDrawers@ in ADT --- @ExportSettings@ for details. -setExportDrawers :: ExportSettingSetter (Either [String] [String]) -setExportDrawers val es = es { exportDrawers = val } +-- | Set export options for sub/superscript parsing. The short syntax will +-- not be parsed if this is set set to @False@. +setExportSmartQuotes :: ExportSettingSetter Bool +setExportSmartQuotes val es = es { exportSmartQuotes = val } -- | Modify a parser state modifyExportSettings :: ExportSettingSetter a -> a -> OrgParserState -> OrgParserState -- cgit v1.2.3