MathJax and miserver
Posted: Thu Nov 02, 2017 9:24 pm
Has anyone used MathJax on an miPage?
The tool of thought for expert programming
https://forums.gos.dyalog.com/
Code: Select all
<Virtual>
<directory>
<alias>MathJax</alias>
<path>%SiteRoot%/MathJax/</path>
</directory>
</Virtual>
Code: Select all
<Resources>
<resource>
<name>MathJax</name>
<script>/MathJax/MathJax.js?config=TeX-MML-AM_CHTML</script>
</resource>
</Resources>
Code: Select all
Use 'MathJax'
Code: Select all
c:\bb\mathjax\Config\Resources.xml
c:\bb\mathjax\Config\Virtual.xml
c:\bb\mathjax\MathJax\ (here is where I unzipped MathJax)
c:\bb\mathjax\index.mipage
Code: Select all
<Resources>
<!--
******************************
* MathJax resources *
******************************
-->
<resource>
<name>MathJax-AsciiMath</name>
<script>/MathJax/MathJax.js?config=AM_CHTML</script>
</resource>
</Resources>
Code: Select all
<Virtual>
<directory>
<alias>MathJax</alias>
<path>%SiteRoot%/MathJax/</path>
</directory>
</Virtual>
Code: Select all
:Class index : MiPage
∇ Compose
:Access Public
Use'MathJax-AsciiMath'
Add'`sum_(i=1)^n i^3=((n(n+1))/2)^2`'
∇
:EndClass
Code: Select all
Add _.body'<script type="text/javascript" src="mathjax/MathJax.js"></script>
Code: Select all
Add _.Script '' 'mathjax/MathJax.js'
Code: Select all
(Add _.script).Set 'src' 'mathjax/MathJax.js'
or
(⊂'src' 'mathjax/MathJax.js') Add _.script
Code: Select all
f1.Add _.div'<p><script type="math/tex">\frac{2}{3}+\sqrt{1-x^2}\hspace{5mm}</script></p>'
Code: Select all
(((f1.Add _.div).Add _.p).Add _.script '\frac{2}{3}+\sqrt{1-x^2}\hspace{5mm}').type←'math/tex'
or
(⊂'type' 'math/tex')((z.Add _.div).Add _.p).Add _.script '\frac{2}{3}+\sqrt{1-x^2}\hspace{5mm}'
Code: Select all
<Resources>
<!--
******************************
* MathJax resources *
******************************
-->
<resource>
<name>MathJax-AsciiMath</name>
<script>/MathJax/MathJax.js?config=AM_CHTML</script>
</resource>
<resource>
<name>MathJax-TeX/LaTeX</name>
<script>/MathJax/MathJax.js?config=TeX-AMS_HTML-full</script>
</resource>
</Resources>
Code: Select all
:Class TeXPage : #.MiPage
∇ {r}←Wrap
:Access Public
Use'MathJax-TeX/LaTeX'
'type=x-mathjax-config'Head.Insert _.Script ScriptFollows
⍝ MathJax.Hub.Config({
⍝ extensions: ["tex2jax.js"],
⍝ jax: ["input/TeX", "output/HTML-CSS"],
⍝ tex2jax: {
⍝ inlineMath: [ ['$','$'], ["\\(","\\)"] ],
⍝ displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
⍝ processEscapes: true
⍝ },
⍝ "HTML-CSS": { availableFonts: ["TeX"] }
⍝ });
r←⎕BASE.Wrap
∇
:EndClass
Code: Select all
:Class TeX : #._html.script
:Field public inline←¯1
:Field public displayed←¯1
∇ Make0
:Access public
:Implements constructor
∇
∇ Make1 params
:Access public
:Implements constructor :base params
∇
∇ r←Render
:Access public
:If UNDEF≡type
type←'math/tex'
:If (inline=0)∨displayed=1
type,←'; mode=display'
:EndIf
:EndIf
r←⎕BASE.Render
∇
:EndClass
Code: Select all
:Class tex : TeXPage
∇ Compose
:Access Public
:With (Add _.div).Set'style' 'width:500px;border-style:solid;padding:10px;'
Add'This is an inline equation '
Add #.TeX'x+\sqrt{1-x^2}'
Add _.br
Add'Whereas this is a displayed (centered on its own line) equation '
(Add #.TeX'x+\sqrt{1-x^2}').displayed←1
:EndWith
∇
:EndClass