aboutsummaryrefslogtreecommitdiff
path: root/source/00_content/pages
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-05-04 23:39:40 +0200
committerAdrian Kummerlaender2016-05-04 23:39:40 +0200
commit67162f80a77a41bc95d7de05a87f7ee9a21a121c (patch)
tree5ee2bcde0c88c63d2a7c2dab20df49c95cdb189b /source/00_content/pages
parentd0ccfca8bc82a01c8d80d24630f54fb6cb76d553 (diff)
downloadblog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar.gz
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar.bz2
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar.lz
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar.xz
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.tar.zst
blog.kummerlaender.eu-67162f80a77a41bc95d7de05a87f7ee9a21a121c.zip
Implement support of server side math expression rendering
Many websites employ the [MathJax](https://www.mathjax.org/) library for dynamically rendering LaTeX math expressions on the client side. I expect to require support for doing just that in the future. But as with syntax highlighting I am of the opinion that this kind of stuff should be performed once during site compilation instead of wasting ressources by forcing each client to do this job for every single page request. Luckily there is a [MathJax-node](https://github.com/mathjax/MathJax-node) module that allows using the _MathJax_ library on the server side. This commit adds support for rendering math expressions written in Markdown respectively LaTeX as follows: `$$1 + 1 \neq 0$$` on the server side. This required the introduction of a new `math_highlighter` helper template in `formatter.xsl` based on the `tex2html` utility provided by _MathJax-node_. This formatter is matched against the (Markdown parser generated) `script` node in `formatter.xsl`'s _embellish_ mode. The HTML rendering of the expression is then embedded in a `p class="math"` node. This explicit labeling allows `master.xsl` to include the `math.css` rules only for pages that actually contain math expressions. Note that the XHTML rendering utility stylesheet `xhtml.xsl` currently adds a XML comment to each `span` node. This is a workaround to prevent _Xalan_ from collapsing "empty" `span` tag pairs into single nodes which otherwise leads to rendering errors as it is not valid HTML and is interpreted as a wrong tree structure by the browser. Note that the CSS rules declared in `math.css` are explicitly not part of the MIT licensed part of this repository but where generated by _MathJax_. As there is currently no _productive_ content making use of math expressions a demo page is available under `page/math_test/`.
Diffstat (limited to 'source/00_content/pages')
-rw-r--r--source/00_content/pages/math_test.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/00_content/pages/math_test.md b/source/00_content/pages/math_test.md
new file mode 100644
index 0000000..d686b76
--- /dev/null
+++ b/source/00_content/pages/math_test.md
@@ -0,0 +1,9 @@
+# Math expression test page
+
+$$\exists \: \epsilon > 0 \: \exists \: N_0 \in N \: \forall \: n \geq N_0 : | f(n) - f(n0) | \leq \epsilon$$
+
+$$\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x$$
+
+$$e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n$$
+
+$$1 + 1 \neq 0$$