Permalink
Browse files

Support mathjax as a math option.

Added MathJax as MathMethod, and mathjax as an option in
the 'math' config field.

Resolves GoogleCode 122.
  • Loading branch information...
1 parent b823b89 commit 1892d65b7cf6428ac1361a4746cad7a25b7c0c0d John MacFarlane committed Sep 3, 2011
Showing with 21 additions and 14 deletions.
  1. +2 −1 Network/Gitit/Config.hs
  2. +3 −1 Network/Gitit/ContentTransformer.hs
  3. +5 −1 Network/Gitit/Layout.hs
  4. +1 −1 Network/Gitit/Types.hs
  5. +10 −10 data/default.conf
@@ -38,7 +38,7 @@ import Data.List (intercalate)
import Data.Char (toLower, toUpper, isDigit)
import Paths_gitit (getDataFileName)
import System.FilePath ((</>))
-import Text.Pandoc hiding (MathML, WebTeX)
+import Text.Pandoc hiding (MathML, WebTeX, MathJax)
forceEither :: Show e => Either e a -> a
forceEither = either (error . show) id
@@ -130,6 +130,7 @@ extractConfig cp = do
, mathMethod = case map toLower cfMathMethod of
"jsmath" -> JsMathScript
"mathml" -> MathML
+ "mathjax" -> MathJax "https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
"google" -> WebTeX "http://chart.apis.google.com/chart?cht=tx&chl="
_ -> RawTeX
, defaultLHS = lhs
@@ -86,7 +86,7 @@ import Prelude hiding (catch)
import System.FilePath
import Text.HTML.SanitizeXSS (sanitizeBalance)
import Text.Highlighting.Kate
-import Text.Pandoc hiding (MathML, WebTeX)
+import Text.Pandoc hiding (MathML, WebTeX, MathJax)
import Text.Pandoc.Shared (ObfuscationMethod(..))
import Text.XHtml hiding ( (</>), dir, method, password, rev )
import qualified Data.Text as T
@@ -347,6 +347,7 @@ pandocToHtml pandocContents = do
case mathMethod cfg of
MathML -> Pandoc.MathML Nothing
WebTeX u -> Pandoc.WebTeX u
+ MathJax u -> Pandoc.MathJax u
_ -> JsMath (Just $ base' ++
"/js/jsMath/easy/load.js")
, writerTableOfContents = toc
@@ -452,6 +453,7 @@ addMathSupport c = do
JsMathScript -> addScripts l ["jsMath/easy/load.js"]
MathML -> addScripts l ["MathMLinHTML.js"]
WebTeX _ -> l
+ MathJax u -> addScripts l [u]
RawTeX -> l
return c
@@ -75,8 +75,12 @@ filledPageTemplate :: String -> Config -> PageLayout -> Html ->
filledPageTemplate base' cfg layout htmlContents templ =
let rev = pgRevision layout
page = pgPageName layout
+ prefixedScript x = case x of
+ 'h':'t':'t':'p':_ -> x
+ _ -> base' ++ "/js/" ++ x
+
scripts = ["jquery.min.js", "jquery-ui.packed.js", "footnotes.js"] ++ pgScripts layout
- scriptLink x = script ! [src (base' ++ "/js/" ++ x),
+ scriptLink x = script ! [src (prefixedScript x),
thetype "text/javascript"] << noHtml
javascriptlinks = renderHtmlFragment $ concatHtml $ map scriptLink scripts
tabli tab = if tab == pgSelectedTab layout
@@ -42,7 +42,7 @@ data PageType = Markdown | RST | LaTeX | HTML | Textile
data FileStoreType = Git | Darcs | Mercurial deriving Show
-data MathMethod = MathML | JsMathScript | WebTeX String | RawTeX
+data MathMethod = MathML | JsMathScript | WebTeX String | RawTeX | MathJax String
deriving (Read, Show, Eq)
data AuthenticationLevel = Never | ForModify | ForRead
View
@@ -61,16 +61,16 @@ default-page-type: Markdown
math: MathML
# specifies how LaTeX math is to be displayed. Possible values
-# are MathML, raw, jsMath, and google. If mathml is selected, gitit will
-# convert LaTeX math to MathML and link in a script, MathMLinHTML.js,
-# that allows the MathML to be seen in Gecko browsers, IE +
-# mathplayer, and Opera. In other browsers you may get a jumble
-# of characters. If raw is selected, the LaTeX math will be displayed
-# as raw LaTeX math. If jsMath is selected, gitit will link to
-# the script /js/jsMath/easy/load.js, and will assume that jsMath
-# has been installed into the js/jsMath directory. This is the most
-# portable solution. If google is selected, the google chart API is
-# called to render the formula as an image. This requires a connection
+# are MathML, raw, mathjax, jsMath, and google. If mathml is selected,
+# gitit will convert LaTeX math to MathML and link in a script,
+# MathMLinHTML.js, that allows the MathML to be seen in Gecko browsers, IE +
+# mathplayer, and Opera. In other browsers you may get a jumble of characters.
+# If raw is selected, the LaTeX math will be displayed as raw LaTeX math.
+# If mathjax is selected, gitit will link to the remote mathjax script.
+# If jsMath is selected, gitit will link to the script /js/jsMath/easy/load.js,
+# and will assume that jsMath has been installed into the js/jsMath directory.
+# This is the most portable solution. If google is selected, the google chart
+# API is called to render the formula as an image. This requires a connection
# to google, and might raise a technical or a privacy problem.
show-lhs-bird-tracks: no

0 comments on commit 1892d65

Please sign in to comment.