asciimath-text-renderer

Crates.ioasciimath-text-renderer
lib.rsasciimath-text-renderer
version0.1.0
sourcesrc
created_at2023-10-03 21:37:45.148611
updated_at2023-10-03 21:37:45.148611
descriptionRender asciimath in terminal
homepagehttps://github.com/Fiedzia/asciimath-text-renderer/
repositoryhttps://github.com/Fiedzia/asciimath-text-renderer/
max_upload_size
id991574
size48,322
Maciej Dziardziel (Fiedzia)

documentation

README

Render asciimath in terminal

Display math formulas as plain text using unicode characters.

This is work in progress, several important parts of spec are not supported yet.

Examples:

The Discrete Fourier Transform is defined as X^k=1/N sum_(n=0)^(N-1)x_n * e^(-ik (2pi)/N n) = 1/N sum_(n=0)^(N-1)x_n[cos(k (2pi)/N n) -i sin(k (2pi)/N n)]

                  2π                                      
              -ik────n                                    
 k  1  N-1         N    1  N-1  ⎡   ⎛  2π  ⎞     ⎛  2π  ⎞⎤
X =───∑   x ⋅e        =───∑   x ⎥cos⎜k────n⎜-isin⎜k────n⎜⎥
    N  n=0 n            N  n=0 n⎣   ⎝   N  ⎠     ⎝   N  ⎠⎦

f(x)=sqrt x + 1/2x^2

        ▁  1  2
f(x)=2╲╱x+───x 
           2   

sqrt x

  ▁
╲╱x

Limitations:

  • cancel cannot be implemented in general. It is possible to replace it with strike-through line for text literals ( cancel x -> x̶ or x̷ or x̸ ), there is no way to do it for expressions.

  • we don't control fonts, therefore fancy text effects are also impossible or very limited (they can be imitated for text literals)

usage:

cargo add asciimath-text-renderer

if you downloaded source, you can run example:

cargo run --example render 'sqrt(2)'
  ▁
╲╱2
Commit count: 26

cargo fmt