This is a Pelican plugin to render AsciiMath . It makes use of Mathjax with config AM_HTMLorMML
and the mathjax script is loaded dynamically, just like render math. But unlike render math , this plugin is very simple as I wrote it for my personal use. Currently, it only supports articles written in restructuredText.
To enable this plugin, simply add the path of this plugin (an absolute path or a relative path to your PLUGIN_PATHS
) to your plugin list in your pelicanconf.py
, for example:
PLUGIN_PATHS = ["plugins"] PLUGINS = ["render_asciimath"]
if file structure is something like:
<project folder> ├── content ├── develop_server.sh ├── fabfile.py ├── Makefile ├── output ├── pelicanconf.py ├── plugins │ ├── extract_toc │ ├── render_asciimath │ ├── render_math │ └── tag_cloud ├── publishconf.py └── themes
Just write it and render your pelican project as usual.
So the solution is :am:`x = (-b +- sqrt(b^2 - 4ac)) / (2a)`.
or:
So the solution is :asciimath:`x = (-b +- sqrt(b^2 - 4ac)) / (2a)`.
is rendered as
If you use a lot of inline AsciiMath in your article and don't want to type the :am:
every time, you can set up the default-role
to AsciiMath. Insert:
.. default-role:: am
to the begining of your article content. And then you can use:
So the solution is `x = (-b +- sqrt(b^2 - 4ac)) / (2a)`.
to write inline AsciiMath. Notice that it is wrapped in single backtick.
.. am:: x = (-b +- sqrt(b^2 - 4ac)) / (2a) int_0^1 f(x)dx where a = 1 b = 2
or:
.. asciimath:: x = (-b +- sqrt(b^2 - 4ac)) / (2a) int_0^1 f(x)dx where a = 1 b = 2
Notice that I add some custom rules.
- Line breaks is preserved. (converted to
<br/>
) - Leading space is preserved. (converted to
'\ '
which is a space in AsciiMath)
You can modify the asciimath.css
. The style is also dynamically added when Pelican compiling the source to html.
- Each inline asciimath is wrap in a
.asciimath-inline
class. - Each line in asciimath directive is wrap in a
.asciimath-line
class and the directive is wrap in.asciimath-block
.
By default, asciimath.css
centeralize the asciimath directive and add some margin between lines in a directive.