aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-06-19 11:10:29 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-06-19 11:10:29 +0200
commitb3041de2fc05b26421c5be4df374ec84aafa11ee (patch)
treeb9381ae7181b8423919cbdc3836f830806d801b5
parentaface549a03c67a5df335863d3b3d00c9c4f3092 (diff)
downloadpandoc-b3041de2fc05b26421c5be4df374ec84aafa11ee.tar.gz
Text.Pandoc.Writers.Math: export defaultMathJaxURL, defaultKaTeXURL.
This will ensure that we only need to update these in one place. (Currently, for example, the mathjax URL is used in both App and trypandoc.) Closes #3685.
-rw-r--r--src/Text/Pandoc/App.hs10
-rw-r--r--src/Text/Pandoc/Writers/Math.hs7
-rw-r--r--trypandoc/trypandoc.hs3
3 files changed, 15 insertions, 5 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 19066e8b7..033614752 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -79,6 +79,7 @@ import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getLog,
setResourcePath, withMediaBag)
import Text.Pandoc.Highlighting (highlightingStyles)
import Text.Pandoc.Lua (runLuaFilter)
+import Text.Pandoc.Writers.Math (defaultMathJaxURL, defaultKaTeXURL)
import Text.Pandoc.PDF (makePDF)
import Text.Pandoc.Process (pipeProcess)
import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
@@ -133,11 +134,11 @@ convertWithOpts opts = do
Nothing -> return Nothing
Just fp -> Just <$> UTF8.readFile fp
- let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css"
let mathMethod =
case (optKaTeXJS opts, optKaTeXStylesheet opts) of
(Nothing, _) -> optHTMLMathMethod opts
- (Just js, ss) -> KaTeX js (fromMaybe csscdn ss)
+ (Just js, ss) -> KaTeX js (fromMaybe
+ (defaultKaTeXURL ++ "katex.min.css") ss)
-- --bibliography implies -F pandoc-citeproc for backwards compatibility:
@@ -1355,7 +1356,8 @@ options =
, Option "" ["mathjax"]
(OptArg
(\arg opt -> do
- let url' = fromMaybe "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML-full" arg
+ let url' = fromMaybe (defaultMathJaxURL ++
+ "MathJax.js?config=TeX-AMS_CHTML-full") arg
return opt { optHTMLMathMethod = MathJax url'})
"URL")
"" -- "Use MathJax for HTML math"
@@ -1364,7 +1366,7 @@ options =
(\arg opt ->
return opt
{ optKaTeXJS =
- arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"})
+ arg <|> Just (defaultKaTeXURL ++ "katex.min.js")})
"URL")
"" -- Use KaTeX for HTML Math
diff --git a/src/Text/Pandoc/Writers/Math.hs b/src/Text/Pandoc/Writers/Math.hs
index 104d3c20b..58252d60f 100644
--- a/src/Text/Pandoc/Writers/Math.hs
+++ b/src/Text/Pandoc/Writers/Math.hs
@@ -1,6 +1,8 @@
module Text.Pandoc.Writers.Math
( texMathToInlines
, convertMath
+ , defaultMathJaxURL
+ , defaultKaTeXURL
)
where
@@ -47,3 +49,8 @@ convertMath writer mt str = do
DisplayMath -> DisplayBlock
InlineMath -> DisplayInline
+defaultMathJaxURL :: String
+defaultMathJaxURL = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/"
+
+defaultKaTeXURL :: String
+defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/"
diff --git a/trypandoc/trypandoc.hs b/trypandoc/trypandoc.hs
index d8652079a..b8b821883 100644
--- a/trypandoc/trypandoc.hs
+++ b/trypandoc/trypandoc.hs
@@ -56,7 +56,8 @@ checkLength t =
writerOpts :: WriterOptions
writerOpts = def { writerReferenceLinks = True,
writerEmailObfuscation = NoObfuscation,
- writerHTMLMathMethod = MathJax "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
+ writerHTMLMathMethod = MathJax (defaultMathJaxURL ++
+ "MathJax.js?config=TeX-AMS_CHTML-full"),
writerHighlightStyle = Just pygments }
readerOpts :: ReaderOptions