
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
// Header
:toc: macro
// Links :example: https://github.com/hacker-dom/adoc-math/raw/main/example/adoc-math-example.pdf[Example] :adoc: https://docs.asciidoctor.org/asciidoc/latest[AsciiDoc] :markdown: https://daringfireball.net/projects/markdown/[Markdown] :latex: https://www.latex-project.org[LaTeX] :adoctor: https://github.com/asciidoctor/asciidoctor[Asciidoctor] :adoctor-pdf: https://github.com/asciidoctor/asciidoctor-pdf[Asciidoctor-Pdf] :adoctorjs: https://github.com/asciidoctor/asciidoctor.js[Asciidoctor.js] :adoc-stem: https://docs.asciidoctor.org/asciidoc/latest/stem/[AsciiDoc STEM] :adoctor-pdf-stem: https://docs.asciidoctor.org/pdf-converter/latest/stem[Asciidoctor-Pdf STEM] :mathjax: https://github.com/mathjax/MathJax-src[MathJax] :katex: https://github.com/KaTeX/KaTeX[KaTeX] :adoc-math: https://github.com/hacker-dom/adoc-math[adoc-math] :adoctor-math: https://github.com/asciidoctor/asciidoctor-mathematical[asciidoctor-mathematical] :amath: http://asciimath.org[AsciiMath]
Use MathJax (Latex or AsciiMath) in your AsciiDoc projects 🤟🚀
toc::[]
adoc-math has zero depependencies! So it's fine to install it globallyfootnote:[Theoretically, the only time this could cause issues is if you have another package which has the name adoc-math (it obviously has to have a different PyPI name, because adoc-math is already taken 😛. But this is not very likely.. )] 😛
npm i -g mathjax@3
and npm link
I think of {adoc} as a markup syntax somewhere between {markdown} and {latex}. It originated with a https://github.com/asciidoc-py/asciidoc-py[Python implementation], but afaik that isn't actively developed, and the reference implementation is {adoctor} in Ruby.
{adoc} allows you to write a document and then output it in:
and many other formats! There is even an {adoctorjs} version (an automated translation of the Ruby code to JavaScript).
Putting LaTeX equations in other places than a TeX document is not so easy. There are two main libraries for this:
STEM stands for Science, Technology, Engineering, Mathematics, basicaly {latex}. There are two sections in the {adoc} documentation on STEM:
TLDR:
stem:[x+y]
. In the browser, {mathjax} is used to render the math, and frankly, it looks beautiful.That's where adoc-math
comes in! I decided for:
$a+b$
), calls {mathjax} to create an svg, and replaces the cells with an image of the svgI couldn't use {katex} because only {mathjax} has an Svg output (see https://github.com/KaTeX/KaTeX/issues/375).
Unfortunately, {mathjax} 3 doesn't come with a Node CLI package like https://github.com/mathjax/mathjax-node-cli/[MathJax 2]. So I implemented xref:./adoc_math/d_mathjax_wrapper.js[a wrapper] over the library.
|===
For more examples, see the {example}.
Why isn't
adoc-math
written in Ruby?
I don't speak Ruby 😞 If you would like to translate this library to Ruby, or at least an AsciiDoc macro that can get replaced by an image, so we cant get rid of the extra metacompilation step, I'd be more than happy to help!
What about Windows?
I tried to be conscious of non-Posix platforms, but haven't tested in on Windows. Any behavioral discrepancies would be considered valid issues.
Can I reference a cell, or add a caption to a block cell?
Yes! Check out the {example}.
It's annoying having to uncomment the source math to edit it.
You can use a pre-post
pattern. pre.adoc
will be your source code, and post.adoc
will be the output of adoc-math
/ input to asciidoctor(-pdf)?
. Run cpy pre.adoc post.adoc
before every invocation to adoc-math
.
How come inline cells become part of the sentence when they are on a separate line?
In {adoc}, you need to separate two blocks with at least one empty line. 🙂
Does
adoc-math
work with an Html output?
This first version is geared towards Pdf output. Happy to add more powerful support for Html outputs in the future (e.g., just use the native stem:[]
macro for Html, so we can use basic {mathjax} with browser fonts and Css (instead of svgs)).
Can I use a different font?
{mathjax} currently http://docs.mathjax.org/en/v3.2-latest/output/fonts.html[doesn't provide support for multiple fonts].
Can I make my math thinner/thicker?
The created svgs have a property called stroke-width
that can adjust this. Unfortunately, it is currently set to 0, so it is not possible to make it thinner. In theory it should be possible to make it thicker by increasing that value. xref:./adoc_math/e_svg_transforming.py[svg_transforming.py] would be the place for that; or create an issue and I'll add it.
I get a MODULE_NOT_FOUND error.
MathJax probably cannot be found. Try running adoc-math-setup
.
My AsciiMath fractions are too large!
It seems that {amath} interprets fractions in displaystyle
rather than textstyle
(\dfrac{}{}
rather than \tfrac{}{}
or even \frac{}{}
, see https://tex.stackexchange.com/a/135395/31626[StackExchange]).
I haven't found a good solution to this yet. If you have any ideas, please let me know! Note that if you have a singleton fraction ($a/b$ amath
) you can scale it down with $a/b$ amath, scale = 60%
(or just use tex
).
FAQs
Use MathJax (Latex or AsciiMath) in your AsciiDoc projects!
We found that adoc-math demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.