diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-06-24 14:46:47 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-06-24 14:57:21 -0700 |
commit | a4294800bfe91976697239ff15c1f87f518df6e8 (patch) | |
tree | f3ca7ecb34cfe2841ca96b6977a5f295af9cccfc /src/Text | |
parent | 5bdf2171351472a4e5804607ee86c1c28268b148 (diff) | |
download | pandoc-a4294800bfe91976697239ff15c1f87f518df6e8.tar.gz |
Make --webtex work with the Markdown writer.
Closes #1177. This is a convenient option for people using
websites whose Markdown flavors don't provide for math.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 1ff8d2ab9..b04e33085 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -55,6 +55,7 @@ import qualified Data.HashMap.Strict as H import qualified Data.Vector as V import qualified Data.Text as T import qualified Data.Set as Set +import Network.HTTP ( urlEncode ) type Notes = [[Block]] type Ref = ([Inline], Target, Attr) @@ -856,18 +857,22 @@ inlineToMarkdown opts (Str str) = do if stPlain st then return $ text str else return $ text $ escapeString opts str -inlineToMarkdown opts (Math InlineMath str) - | isEnabled Ext_tex_math_dollars opts = - return $ "$" <> text str <> "$" - | isEnabled Ext_tex_math_single_backslash opts = - return $ "\\(" <> text str <> "\\)" - | isEnabled Ext_tex_math_double_backslash opts = - return $ "\\\\(" <> text str <> "\\\\)" - | otherwise = do - plain <- gets stPlain - inlineListToMarkdown opts $ - (if plain then makeMathPlainer else id) $ - texMathToInlines InlineMath str +inlineToMarkdown opts (Math InlineMath str) = + case writerHTMLMathMethod opts of + WebTeX url -> + inlineToMarkdown opts (Image nullAttr [Str str] + (url ++ urlEncode str, str)) + _ | isEnabled Ext_tex_math_dollars opts -> + return $ "$" <> text str <> "$" + | isEnabled Ext_tex_math_single_backslash opts -> + return $ "\\(" <> text str <> "\\)" + | isEnabled Ext_tex_math_double_backslash opts -> + return $ "\\\\(" <> text str <> "\\\\)" + | otherwise -> do + plain <- gets stPlain + inlineListToMarkdown opts $ + (if plain then makeMathPlainer else id) $ + texMathToInlines InlineMath str inlineToMarkdown opts (Math DisplayMath str) | isEnabled Ext_tex_math_dollars opts = return $ "$$" <> text str <> "$$" |