summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org/ParserState.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2016-06-02 22:17:46 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2016-06-03 11:16:35 +0200
commit952a7dac589107cc19e606ff9cf29dfbb33002bc (patch)
tree42f414b079f2ba530ad29565dfb288128a41c1cf /src/Text/Pandoc/Readers/Org/ParserState.hs
parent729fca311fed275a8000d2ce3789d985133c34fc (diff)
Org reader: support smart quotes export option
Reading of smart quotes can be toggled using the `'` option.
Diffstat (limited to 'src/Text/Pandoc/Readers/Org/ParserState.hs')
-rw-r--r--src/Text/Pandoc/Readers/Org/ParserState.hs31
1 files changed, 22 insertions, 9 deletions
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 <http://orgmode.org/manual/Export-settings.html>
-- 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