summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs2
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs15
-rw-r--r--src/Text/Pandoc/Readers/Org/ParserState.hs26
3 files changed, 28 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
index 9019f44fb..896f1da1a 100644
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -501,7 +501,7 @@ exportSetting :: OrgParser ()
exportSetting = choice
[ booleanSetting "^" setExportSubSuperscripts
, booleanSetting "'" setExportSmartQuotes
- , ignoredSetting "*"
+ , booleanSetting "*" setExportEmphasizedText
, ignoredSetting "-"
, ignoredSetting ":"
, ignoredSetting "<"
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index 80a94f1b3..fdefd2a3f 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -108,10 +108,7 @@ inline =
, inlineCodeBlock
, str
, endline
- , emph
- , strong
- , strikeout
- , underline
+ , emphasizedText
, code
, math
, displayMath
@@ -443,6 +440,16 @@ inlineCodeBlock = try $ do
<* skipSpaces
+emphasizedText :: OrgParser (F Inlines)
+emphasizedText = do
+ state <- getState
+ guard . exportEmphasizedText . orgStateExportSettings $ state
+ try $ choice
+ [ emph
+ , strong
+ , strikeout
+ , underline
+ ]
enclosedByPair :: Char -- ^ opening char
-> Char -- ^ closing char
diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs
index d566346e8..2fa5d920b 100644
--- a/src/Text/Pandoc/Readers/Org/ParserState.hs
+++ b/src/Text/Pandoc/Readers/Org/ParserState.hs
@@ -43,6 +43,7 @@ module Text.Pandoc.Readers.Org.ParserState
, ExportSettingSetter
, ExportSettings (..)
, setExportDrawers
+ , setExportEmphasizedText
, setExportSmartQuotes
, setExportSubSuperscripts
, modifyExportSettings
@@ -83,26 +84,27 @@ data ExportSettings = ExportSettings
-- ^ 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.
+ , exportEmphasizedText :: Bool -- ^ Parse emphasized text.
, exportSmartQuotes :: Bool -- ^ Parse quotes, ellipses, apostrophs smartly
, exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
}
-- | Org-mode parser state
data OrgParserState = OrgParserState
- { orgStateOptions :: ReaderOptions
- , orgStateAnchorIds :: [String]
+ { orgStateAnchorIds :: [String]
, orgStateEmphasisCharStack :: [Char]
, orgStateEmphasisNewlines :: Maybe Int
, orgStateExportSettings :: ExportSettings
+ , orgStateHeaderMap :: M.Map Inlines String
+ , orgStateIdentifiers :: Set.Set String
, orgStateLastForbiddenCharPos :: Maybe SourcePos
, orgStateLastPreCharPos :: Maybe SourcePos
, orgStateLastStrPos :: Maybe SourcePos
, orgStateLinkFormatters :: OrgLinkFormatters
, orgStateMeta :: F Meta
, orgStateNotes' :: OrgNoteTable
+ , orgStateOptions :: ReaderOptions
, orgStateParserContext :: ParserContext
- , orgStateIdentifiers :: Set.Set String
- , orgStateHeaderMap :: M.Map Inlines String
}
data OrgParserLocal = OrgParserLocal { orgLocalQuoteContext :: QuoteContext }
@@ -137,25 +139,26 @@ instance Default OrgParserState where
defaultOrgParserState :: OrgParserState
defaultOrgParserState = OrgParserState
- { orgStateOptions = def
- , orgStateAnchorIds = []
+ { orgStateAnchorIds = []
, orgStateEmphasisCharStack = []
, orgStateEmphasisNewlines = Nothing
, orgStateExportSettings = def
+ , orgStateHeaderMap = M.empty
+ , orgStateIdentifiers = Set.empty
, orgStateLastForbiddenCharPos = Nothing
, orgStateLastPreCharPos = Nothing
, orgStateLastStrPos = Nothing
, orgStateLinkFormatters = M.empty
, orgStateMeta = return nullMeta
, orgStateNotes' = []
+ , orgStateOptions = def
, orgStateParserContext = NullState
- , orgStateIdentifiers = Set.empty
- , orgStateHeaderMap = M.empty
}
defaultExportSettings :: ExportSettings
defaultExportSettings = ExportSettings
{ exportDrawers = Left ["LOGBOOK"]
+ , exportEmphasizedText = True
, exportSmartQuotes = True
, exportSubSuperscripts = True
}
@@ -175,13 +178,16 @@ type ExportSettingSetter a = a -> ExportSettings -> ExportSettings
setExportDrawers :: ExportSettingSetter (Either [String] [String])
setExportDrawers val es = es { exportDrawers = val }
+-- | Set export options for emphasis parsing.
+setExportEmphasizedText :: ExportSettingSetter Bool
+setExportEmphasizedText val es = es { exportEmphasizedText = 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 sub/superscript parsing. The short syntax will
--- not be parsed if this is set set to @False@.
+-- | Set export options for parsing of smart quotes.
setExportSmartQuotes :: ExportSettingSetter Bool
setExportSmartQuotes val es = es { exportSmartQuotes = val }