Skip to content

Commit e0624ce

Browse files
committed
(25) Fixes theam#25
1 parent 7a31007 commit e0624ce

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

src/common/HaskellDo/State.hs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import qualified HaskellDo.Compilation.Types as Compilation
3333
import qualified HaskellDo.Toolbar.State as Toolbar
3434
import qualified HaskellDo.Toolbar.Types as Toolbar
3535
import qualified Foreign.JQuery as JQuery
36+
import qualified Foreign.MathJax as MathJax
3637

3738
initialAppState :: AppState
3839
initialAppState = AppState
@@ -98,6 +99,7 @@ _update (ToolbarAction Toolbar.Compile) appState = do
9899
Compilation.Compile
99100
(compilationState appState)
100101
localIO $ JQuery.hide ".dimmedBackground"
102+
localIO $ MathJax.typeset "outputDisplay"
101103
return appState
102104
{ compilationState = newCompilationState
103105
}

src/ghc-specific/Foreign/MathJax.hs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Foreign.MathJax where
2+
3+
typeset :: String -> IO ()
4+
typeset _ = return ()
5+

src/ghcjs-specific/Foreign/MathJax.hs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Foreign.MathJax where
2+
3+
import GHCJS.Types
4+
import Data.JSString
5+
6+
foreign import javascript unsafe "MathJax.Hub.Queue(['Typeset', MathJax.Hub, $1]);"
7+
js_typeset :: JSString -> IO ()
8+
9+
typeset :: String -> IO ()
10+
typeset = js_typeset . pack
11+

static/out.jsexe/index.html

+8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/mode/haskell/haskell.min.js"></script>
4141
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/mode/htmlmixed/htmlmixed.min.js"></script>
4242
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.2/mode/meta.min.js"></script>
43+
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'></script>
4344
<script>
45+
MathJax.Hub.Config({
46+
tex2jax: {
47+
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
48+
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
49+
processEscapes: false,
50+
}
51+
})
4452
let cmdOrCtrlReturnPressed = false;
4553
let alreadyHighlighted = false;
4654
</script>

0 commit comments

Comments
 (0)