-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Describe the bug
MathJax is a JavaScript library allowing to add "custom tags" such as $...$
to HTML which will then be turned into e.g., MathML or whatever the browser supports.
Depending on the Markdown implementation math is either not supported at all -- or directly through the same syntax. Either way, it'd probably make most sense to simply keep $...$
expressions intact and not escape strings contained therein. While a simple filter for that would certainly work, MathJax allows supporting different escape characters than $...$
for inline- and $$...$$
for display-math, e.g., from the article https://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/:
<script>
window.MathJax = {
tex: {
tags: "ams", inlineMath: [ ['$','$'], ['\\(', '\\)'] ],
displayMath: [ ['$$','$$'] ],
processEscapes: true,
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
loader: {
load: ['[tex]/amscd'] }
};
</script>
This would necessate parsing Js though ...
HTML Input
some formula: $\lambda$
Generated Markdown
some formula: $\\lambda$
Expected Markdown
some formula: $\lambda$
Additional context
This filter (or "unfilter") may be only activated, if MathJax is detected, and otherwise disabled. Further, as mentioned earlier, a more sophisticated parsing of the HTML may be used to detect the precise math-HTML tags used or make them configurable at the least.