beef331 / website

Code for the official Nim programming language website
https://nim-lang.org
19 stars 1 forks source link

Submission: maTeXt #54

Closed xigoi closed 2 years ago

xigoi commented 2 years ago

Name: maTeXt

Author: xigoi (Adam Blažek)

Posting:

Communicating online about math is often difficult. The notation uses many characters that are hard to type and makes liberal use of fonts and two-dimensional layout. To deal with this, there's the awesome (La)TeX typesetting system and tools like KaTeX that allow using it on the web, but sometimes that's not possible — for example, when using a text messaging app or publishing articles using the Gemini protocol.

That's why I created maTeXt, a library and CLI application that renders LaTeX math to plain text using Unicode math characters. For vertical notation, it uses multiple lines and assumes a monospace font, but in case that's not available, it also supports one-line mode.

Here is an example of the quadratic formula in LaTeX, multiline maTeXt and one-line maTeXt. (The multiline version may look broken because of a bad monospace font.)

x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
                 ________
                ╱ 2      
        − 𝑏 ± ╲╱ 𝑏  − 4𝑎𝑐
𝑥     = ─────────────────
 1, 2          2𝑎        
𝑥_(1, 2) = (− 𝑏 ± √(𝑏² − 4𝑎𝑐)) / (2𝑎)

Currently, not all notation is supported; I'm intending to improve that. Obviously you can also contribute if you want.

Thanks to the authors of honeycomb and cligen and to the Unicode Table for making this possible.