@@ -42,6 +42,7 @@ import Text.Pandoc.Pretty
4242import Control.Monad.State
4343import qualified Data.Set as Set
4444import Text.Pandoc.Writers.HTML (writeHtmlString)
45+import Text.Pandoc.Readers.TeXMath (readTeXMath)
4546import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..))
4647
4748type Notes = [[Block]]
@@ -531,10 +532,23 @@ inlineToMarkdown _ (Str str) = do
531532 if stPlain st
532533 then return $ text str
533534 else return $ text $ escapeString str
534−inlineToMarkdown _ (Math InlineMath str) =
535− return $ "$" <> text str <> "$"
536−inlineToMarkdown _ (Math DisplayMath str) =
537− return $ "$$" <> text str <> "$$"
535+inlineToMarkdown opts (Math InlineMath str)
536+ | isEnabled Ext_tex_math_dollars opts =
537+ return $ "$" <> text str <> "$"
538+ | isEnabled Ext_tex_math_single_backslash opts =
539+ return $ "\\(" <> text str <> "\\)"
540+ | isEnabled Ext_tex_math_double_backslash opts =
541+ return $ "\\\\(" <> text str <> "\\\\)"
542+ | otherwise = inlineListToMarkdown opts $ readTeXMath str
543+inlineToMarkdown opts (Math DisplayMath str)
544+ | isEnabled Ext_tex_math_dollars opts =
545+ return $ "$$" <> text str <> "$$"
546+ | isEnabled Ext_tex_math_single_backslash opts =
547+ return $ "\\[" <> text str <> "\\]"
548+ | isEnabled Ext_tex_math_double_backslash opts =
549+ return $ "\\\\[" <> text str <> "\\\\]"
550+ | otherwise = (\x -> cr <> x <> cr) `fmap`
551+ inlineListToMarkdown opts (readTeXMath str)
538552inlineToMarkdown opts (RawInline f str)
539553 | f == "html" || f == "markdown" ||
540554 (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) =