Forester, a tool for scientific and mathematical hypertexts

https://news.ycombinator.com/rss Hits: 2
Summary

makes it possible (see ) to write MathML directly as an alternative to using Forester’s TeX-like math mode via KaTeX. For example, we can write the following wrappers for some basic MathML elements:{\body}} \def\mrow[body]{\{\body}} \def\mi[x]{\{\x}} \def\mo[o]{\{\o}} \def\mn[n]{\{\n}}]]>With this in hand, we can write prose involving MathML content, like so:The above is a bit messy. We can clean it up with some function definitions:It is annoying that we have to always wrap things in . By combining first-class functions, lazy arguments, and fluid bindings, we can lift this requirement: element. \def\ensure-math[~body]{% \scope{% % Set a default value for \math-wrapper (no-op if already set). \put?\math-wrapper{\fun[x]{\{\x}}}% % % Apply the current function bound to \math-wrapper. \get\math-wrapper{% % Bind \math-wrapper to the identity function in the current scope so that % we do not get redundant nodes. \put\math-wrapper{\fun[x]{\x}}% % % Force the \body thunk to evaluate the body within the wrapper. \body{}% }% }% }]]>We now re-define our macro library to use the :{\x{}}}} \def\mi[~x]{\ensure-math{\{\x{}}}} \def\mo[~x]{\ensure-math{\{\x{}}}} \def\mn[~x]{\ensure-math{\{\x{}}}} \def\plus[~x][~y]{\mrow{\x{} \mo{+} \y{}}} \def\equals[~x][~y]{\mrow{\x{} \mo{=} \y{}}}]]>Now, we can put MathML content freely into prose without needing to wrap it each time.

First seen: 2025-05-27 03:54

Last seen: 2025-05-27 04:54