summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Org.hs5
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs2
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs2
-rw-r--r--src/Text/Pandoc/Readers/Org/ParserState.hs31
4 files changed, 28 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 1042b5a21..d593f856d 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -29,7 +29,7 @@ module Text.Pandoc.Readers.Org ( readOrg ) where
import Text.Pandoc.Readers.Org.Blocks ( blockList, meta )
import Text.Pandoc.Readers.Org.Parsing ( OrgParser, readWithM )
-import Text.Pandoc.Readers.Org.ParserState ( OrgParserState (..) )
+import Text.Pandoc.Readers.Org.ParserState ( optionsToParserState )
import Text.Pandoc.Definition
import Text.Pandoc.Error
@@ -42,7 +42,8 @@ import Control.Monad.Reader ( runReader )
readOrg :: ReaderOptions -- ^ Reader options
-> String -- ^ String to parse (assuming @'\n'@ line endings)
-> Either PandocError Pandoc
-readOrg opts s = flip runReader def $ readWithM parseOrg def{ orgStateOptions = opts } (s ++ "\n\n")
+readOrg opts s = flip runReader def $
+ readWithM parseOrg (optionsToParserState opts) (s ++ "\n\n")
--
-- Parser
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
index 52db466a4..9019f44fb 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -500,7 +500,7 @@ addLinkFormat key formatter = updateState $ \s ->
exportSetting :: OrgParser ()
exportSetting = choice
[ booleanSetting "^" setExportSubSuperscripts
- , ignoredSetting "'"
+ , booleanSetting "'" setExportSmartQuotes
, ignoredSetting "*"
, ignoredSetting "-"
, ignoredSetting ":"
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index be7fc600a..80a94f1b3 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -730,6 +730,7 @@ smart = do
singleQuoted :: OrgParser (F Inlines)
singleQuoted = try $ do
+ guard . exportSmartQuotes . orgStateExportSettings =<< getState
singleQuoteStart
updatePositions '\''
withQuoteContext InSingleQuote $
@@ -741,6 +742,7 @@ singleQuoted = try $ do
-- in the same paragraph.
doubleQuoted :: OrgParser (F Inlines)
doubleQuoted = try $ do
+ guard . exportSmartQuotes . orgStateExportSettings =<< getState
doubleQuoteStart
updatePositions '"'
contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
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