aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Soon <[email protected]>2025-08-09 19:40:59 +0100
committerGitHub <[email protected]>2025-08-09 20:40:59 +0200
commit661a0b51a44a5f16c31cc245b5c8635d548ddc2b (patch)
tree7ccaabad76f3b56023e93d33db52184788789d31
parent7639e800c5af85e5ded862a6e218d54489d17bfc (diff)
T.P.Options: Add and export `defaultWebTeXURL` WebTeX URL [API change] (#11029)
This fixes the `webtex` option when used without parameter in a defaults file.
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs4
-rw-r--r--src/Text/Pandoc/Options.hs9
2 files changed, 9 insertions, 4 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
index 56c855e5f..b28013107 100644
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -1023,8 +1023,8 @@ options =
, Option "" ["webtex"]
(OptArg
(\arg opt -> do
- let url' = fromMaybe "https://latex.codecogs.com/png.latex?" arg
- return opt { optHTMLMathMethod = WebTeX $ T.pack url' })
+ let url' = maybe defaultWebTeXURL T.pack arg
+ return opt { optHTMLMathMethod = WebTeX url' })
"URL")
"" -- "Use web service for HTML math"
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 34d48fc56..43df5c27f 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -32,6 +32,7 @@ module Text.Pandoc.Options ( module Text.Pandoc.Extensions
, def
, isEnabled
, defaultMathJaxURL
+ , defaultWebTeXURL
, defaultKaTeXURL
) where
import Control.Applicative ((<|>))
@@ -114,7 +115,8 @@ instance FromJSON HTMLMathMethod where
mburl <- m .:? "url"
case method :: Text of
"plain" -> return PlainMath
- "webtex" -> return $ WebTeX $ fromMaybe "" mburl
+ "webtex" -> return $ WebTeX $
+ fromMaybe defaultWebTeXURL mburl
"gladtex" -> return GladTeX
"mathml" -> return MathML
"mathjax" -> return $ MathJax $
@@ -124,7 +126,7 @@ instance FromJSON HTMLMathMethod where
_ -> fail $ "Unknown HTML math method " ++ show method) node
<|> (case node of
String "plain" -> return PlainMath
- String "webtex" -> return $ WebTeX ""
+ String "webtex" -> return $ WebTeX defaultWebTeXURL
String "gladtex" -> return GladTeX
String "mathml" -> return MathML
String "mathjax" -> return $ MathJax defaultMathJaxURL
@@ -402,6 +404,9 @@ isEnabled ext opts = ext `extensionEnabled` getExtensions opts
defaultMathJaxURL :: Text
defaultMathJaxURL = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"
+defaultWebTeXURL :: Text
+defaultWebTeXURL = "https://latex.codecogs.com/png.latex?"
+
defaultKaTeXURL :: Text
defaultKaTeXURL = "https://cdn.jsdelivr.net/npm/katex@latest/dist/"