diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ExportSettings.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Inlines.hs | 18 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ParserState.hs | 2 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs index ab402b8c9..206c8ba92 100644 --- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs +++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs @@ -47,7 +47,7 @@ exportSetting = choice , booleanSetting "creator" (\val es -> es { exportWithCreator = val }) , complementableListSetting "d" (\val es -> es { exportDrawers = val }) , ignoredSetting "date" - , ignoredSetting "e" + , booleanSetting "e" (\val es -> es { exportWithEntities = val }) , booleanSetting "email" (\val es -> es { exportWithEmail = val }) , ignoredSetting "f" , integerSetting "H" (\val es -> es { exportHeadlineLevels = val }) 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 = diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index 289b64193..ac826b6f9 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -257,6 +257,7 @@ data ExportSettings = ExportSettings , exportWithAuthor :: Bool -- ^ Include author in final meta-data , exportWithCreator :: Bool -- ^ Include creator in final meta-data , exportWithEmail :: Bool -- ^ Include email in final meta-data + , exportWithEntities :: Bool -- ^ Include MathML-like entities , exportWithLatex :: TeXExport -- ^ Handling of raw TeX commands , exportWithPlanning :: Bool -- ^ Keep planning info after headlines , exportWithTags :: Bool -- ^ Keep tags as part of headlines @@ -279,6 +280,7 @@ defaultExportSettings = ExportSettings , exportWithAuthor = True , exportWithCreator = True , exportWithEmail = True + , exportWithEntities = True , exportWithLatex = TeXExport , exportWithPlanning = False , exportWithTags = True |