Last active
August 2, 2022 07:51
-
-
Save jeroen/74e2a694deed267bed96c478fee2f6c3 to your computer and use it in GitHub Desktop.
Validates mathjax using katex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctx <- V8::v8() | |
ctx$source('https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js') | |
ctx$eval('function validate(s){var out = {result: "ok", warnings:[]}; try{console.warn=function(w){out.warnings.push(w);};katex.renderToString(s)} catch (e) {out.result = e.name; out.position = e.position; out.message = e.message}; return out;}') | |
# Parsing error | |
ctx$call('validate', "E(y) = \\boldmath{\\mu}") | |
# OK but with warnings: | |
ctx$call('validate', "s*ₓᵢ = sₓᵢ √(VIFₓᵢ⁻¹) √((n-1)/(n-p))") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment