@@ -58,7 +58,7 @@ import qualified Control.Exception as E
5858import Control.Exception.Extensible ( throwIO )
5959import qualified Text.Pandoc.UTF8 as UTF8
6060import Control.Monad (when, unless, (>=>))
61−import Data.Maybe (isJust)
61+import Data.Maybe (isJust, fromMaybe)
6262import Data.Foldable (foldrM)
6363import Network.URI (parseURI, isURI, URI(..))
6464import qualified Data.ByteString.Lazy as B
@@ -68,7 +68,7 @@ import qualified Data.Map as M
6868import Data.Yaml (decode)
6969import qualified Data.Yaml as Yaml
7070import qualified Data.Text as T
71−import Control.Applicative ((<$>))
71+import Control.Applicative ((<$>), (<|>))
7272import Text.Pandoc.Readers.Txt2Tags (getT2TMeta)
7373import Data.Monoid
7474
@@ -205,6 +205,8 @@ data Opt = Opt
205205 , optExtractMedia :: Maybe FilePath -- ^ Path to extract embedded media
206206 , optTrace :: Bool -- ^ Print debug information
207207 , optTrackChanges :: TrackChanges -- ^ Accept or reject MS Word track-changes.
208+ , optKaTeXStylesheet :: Maybe String -- ^ Path to stylesheet for KaTeX
209+ , optKaTeXJS :: Maybe String -- ^ Path to js file for KaTeX
208210 }
209211
210212-- | Defaults for command-line options.
@@ -263,6 +265,8 @@ defaultOpts = Opt
263265 , optExtractMedia = Nothing
264266 , optTrace = False
265267 , optTrackChanges = AcceptChanges
268+ , optKaTeXStylesheet = Nothing
269+ , optKaTeXJS = Nothing
266270 }
267271
268272-- | A list of functions, each transforming the options data structure
@@ -818,6 +822,21 @@ options =
818822 return opt { optHTMLMathMethod = MathJax url'})
819823 "URL")
820824 "" -- "Use MathJax for HTML math"
825+ , Option "" ["katex"]
826+ (OptArg
827+ (\arg opt ->
828+ return opt
829+ { optKaTeXJS =
830+ arg <|> Just "http://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.0/katex.min.js"})
831+ "URL")
832+ "" -- Use KaTeX for HTML Math
833+
834+ , Option "" ["katex-stylesheet"]
835+ (ReqArg
836+ (\arg opt ->
837+ return opt { optKaTeXStylesheet = Just arg })
838+ "URL")
839+ "" -- Set the KaTeX Stylesheet location
821840
822841 , Option "" ["gladtex"]
823842 (NoArg
@@ -860,6 +879,7 @@ options =
860879
861880 ]
862881
882+
863883addMetadata :: String -> MetaValue -> M.Map String MetaValue
864884 -> M.Map String MetaValue
865885addMetadata k v m = case M.lookup k m of
@@ -1027,7 +1047,7 @@ main = do
10271047 , optHighlight = highlight
10281048 , optHighlightStyle = highlightStyle
10291049 , optChapters = chapters
1030− , optHTMLMathMethod = mathMethod
1050+ , optHTMLMathMethod = mathMethod'
10311051 , optReferenceODT = referenceODT
10321052 , optReferenceDocx = referenceDocx
10331053 , optEpubStylesheet = epubStylesheet
@@ -1056,6 +1076,8 @@ main = do
10561076 , optExtractMedia = mbExtractMedia
10571077 , optTrace = trace
10581078 , optTrackChanges = trackChanges
1079+ , optKaTeXStylesheet = katexStylesheet
1080+ , optKaTeXJS = katexJS
10591081 } = opts
10601082
10611083 when dumpArgs $
@@ -1063,6 +1085,13 @@ main = do
10631085 mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args
10641086 exitWith ExitSuccess
10651087
1088+ let csscdn = "http://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.0/katex.min.css"
1089+ let mathMethod =
1090+ case (katexJS, katexStylesheet) of
1091+ (Nothing, _) -> mathMethod'
1092+ (Just js, ss) -> KaTeX js (fromMaybe csscdn ss)
1093+
1094+
10661095 -- --bibliography implies -F pandoc-citeproc for backwards compatibility:
10671096 let needsCiteproc = isJust (M.lookup "bibliography" metadata) &&
10681097 optCiteMethod opts `notElem` [Natbib, Biblatex] &&