aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org/Inlines.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2020-06-30 11:36:10 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2020-06-30 11:39:32 +0200
commit7c207c3051d233d99737c52bb86513d4033f69e9 (patch)
treea7b883aff64cc1a4385980a16c04d15c35a20bdd /src/Text/Pandoc/Readers/Org/Inlines.hs
parentc212886d2b117340d38f3e14c08a4d0480adb46f (diff)
downloadpandoc-7c207c3051d233d99737c52bb86513d4033f69e9.tar.gz
Org reader: respect export setting which disables entities
MathML-like entities, e.g., `\alpha`, can be disabled with the `#+OPTION: e:nil` export setting.
Diffstat (limited to 'src/Text/Pandoc/Readers/Org/Inlines.hs')
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index d589dd042..13b1315b8 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -790,9 +790,12 @@ inlineLaTeX :: PandocMonad m => OrgParser m (F Inlines)
inlineLaTeX = try $ do
cmd <- inlineLaTeXCommand
texOpt <- getExportSetting exportWithLatex
+ allowEntities <- getExportSetting exportWithEntities
ils <- parseAsInlineLaTeX cmd texOpt
maybe mzero returnF $
- parseAsMathMLSym cmd `mplus` parseAsMath cmd texOpt `mplus` ils
+ parseAsMathMLSym allowEntities cmd `mplus`
+ parseAsMath cmd texOpt `mplus`
+ ils
where
parseAsInlineLaTeX :: PandocMonad m
=> Text -> TeXExport -> OrgParser m (Maybe Inlines)
@@ -801,10 +804,15 @@ inlineLaTeX = try $ do
TeXIgnore -> return (Just mempty)
TeXVerbatim -> return (Just $ B.str cs)
- parseAsMathMLSym :: Text -> Maybe Inlines
- parseAsMathMLSym cs = B.str <$> MathMLEntityMap.getUnicode (clean cs)
- -- drop initial backslash and any trailing "{}"
- where clean = T.dropWhileEnd (`elem` ("{}" :: String)) . T.drop 1
+ parseAsMathMLSym :: Bool -> Text -> Maybe Inlines
+ parseAsMathMLSym allowEntities cs = do
+ -- drop initial backslash and any trailing "{}"
+ let clean = T.dropWhileEnd (`elem` ("{}" :: String)) . T.drop 1
+ -- If entities are disabled, then return the string as text, but
+ -- only if this *is* a MathML entity.
+ case B.str <$> MathMLEntityMap.getUnicode (clean cs) of
+ Just _ | not allowEntities -> Just $ B.str cs
+ x -> x
state :: ParserState
state = def{ stateOptions = def{ readerExtensions =