Coding dynamic mathematical content is easier in a JavaScript file like this, where we make use of template literals.
The mathsvex
preprocessor will look at files ending with .math.js
(or ts). These
files should define a contents file, which is either a Markdown string or an array (see
the next example). Any math delimited by dollar signs will be handled accordingly.
This value and the following are generated dynamically:
Reload the page to see new values.
const x = Math.ceil(Math.random() * 100);
export const contents =
`# Dynamic math in markdown
Coding *dynamic* mathematical content
...
## Demo
This value $ x=${x} $ and the following are generated dynamically:
$$ x^2 = ${x * x} $$
Reload the page to see new values.
`