git.iko.soy/typeable/pandoc
on master help sign in
Make --webtex work with the Markdown writer.
a429480John MacFarlane
@@ -949,6 +949,8 @@ Math rendering in HTML
949: Render TeX formulas using an external script that converts TeX
949: Render TeX formulas using an external script that converts TeX
950 formulas to images. The formula will be concatenated with the URL
950 formulas to images. The formula will be concatenated with the URL
951 provided. If *URL* is not specified, the Google Chart API will be used.
951 provided. If *URL* is not specified, the Google Chart API will be used.
952+ Note: the `--webtex` option will affect Markdown output
953+ as well as HTML.
952
954
953`--katex`[`=`*URL*]
955`--katex`[`=`*URL*]
954
956
src/Text/Pandoc/Writers/Markdown.hs+17−12
@@ -55,6 +55,7 @@ import qualified Data.HashMap.Strict as H
55import qualified Data.Vector as V
55import qualified Data.Vector as V
56import qualified Data.Text as T
56import qualified Data.Text as T
57import qualified Data.Set as Set
57import qualified Data.Set as Set
58+import Network.HTTP ( urlEncode )
58
59
59type Notes = [[Block]]
60type Notes = [[Block]]
60type Ref = ([Inline], Target, Attr)
61type Ref = ([Inline], Target, Attr)
@@ -856,18 +857,22 @@ inlineToMarkdown opts (Str str) = do
856 if stPlain st
857 if stPlain st
857 then return $ text str
858 then return $ text str
858 else return $ text $ escapeString opts str
859 else return $ text $ escapeString opts str
859−inlineToMarkdown opts (Math InlineMath str)
860+inlineToMarkdown opts (Math InlineMath str) =
861+ case writerHTMLMathMethod opts of
862+ WebTeX url ->
863+ inlineToMarkdown opts (Image nullAttr [Str str]
864+ (url ++ urlEncode str, str))
860− | isEnabled Ext_tex_math_dollars opts =
865+ _ | isEnabled Ext_tex_math_dollars opts ->
861− return $ "$" <> text str <> "$"
866+ return $ "$" <> text str <> "$"
862− | isEnabled Ext_tex_math_single_backslash opts =
867+ | isEnabled Ext_tex_math_single_backslash opts ->
863− return $ "\\(" <> text str <> "\\)"
868+ return $ "\\(" <> text str <> "\\)"
864− | isEnabled Ext_tex_math_double_backslash opts =
869+ | isEnabled Ext_tex_math_double_backslash opts ->
865− return $ "\\\\(" <> text str <> "\\\\)"
870+ return $ "\\\\(" <> text str <> "\\\\)"
866− | otherwise = do
871+ | otherwise -> do
867− plain <- gets stPlain
872+ plain <- gets stPlain
868− inlineListToMarkdown opts $
873+ inlineListToMarkdown opts $
869− (if plain then makeMathPlainer else id) $
874+ (if plain then makeMathPlainer else id) $
870− texMathToInlines InlineMath str
875+ texMathToInlines InlineMath str
871inlineToMarkdown opts (Math DisplayMath str)
876inlineToMarkdown opts (Math DisplayMath str)
872 | isEnabled Ext_tex_math_dollars opts =
877 | isEnabled Ext_tex_math_dollars opts =
873 return $ "$$" <> text str <> "$$"
878 return $ "$$" <> text str <> "$$"