1.0.2 • Published 3 years ago

ppmath v1.0.2

Weekly downloads
4
License
GPL-3.0
Repository
github
Last release
3 years ago

ppmath

This command-line tool processes a text file (usually html) which includes Tex maths formulae. It makes an image for each formula which it places in a directory named 'images'. It produces another file where each formula is replaced by a link to an image.

Installation

First, nodejs and npm must be installed on your computer. The procedure varies with the operating system:

For Linux, nodejs and npm can be installed from the distribution.

For Windows, download and run the installer from https://nodejs.org.

For Mac, ?

Then open a command prompt console and type:

npm install -g ppmath

There may be few warning messages; these can safely be ignored. The tool can then be used from any directory.

Use

The tool is run from a command prompt console. Make a directory where you want to work and place the file you want to convert in it.

Type

ppmconvert -i infile -o outfile

where infile is the file to convert and outfile will be the converted file. The image files will be placed in a subdirectory of the working directory called "images". This directory will be created if it does not already exist.

The program will normally run until the conversion is complete. It prints dots to show its progress. Pressing ctrl-c will stop the run.

In the converted file the maths expressions, delimited by the tags \[ and \] for 'display' expressions or \( and \) for 'inline' expressions, are replaced by <img> links.

The 'alt' attribute of the <img> will contain a text description of the formula which can be read by a screen-reader.

This will be in English by default. To use another language add an extra option on the command line -l code. Possible language codes from ISO 639-1 are (at Nov. 2020) en, es, fr, de. This function is provided by speech-rule-engine.

The 'data-tex' attribute will contain the original maths expression (with the backslashes in the begin and end markers removed).

If the program detects any tags that do not match up correctly, or if a problem occurs interpreting the markup it will print a message at the terminal and also insert the message in the output file and continue working. The messages are surrounded by 7 asterisks.

Notes

Images

The tool makes SVG images using Mathjax-node. The names of the images are generated by a "fingerprint" function (md5) from the maths expressions. Any duplicated expressions will link to the same image.

The display images are centre-aligned. This is done by css. The html (or associated css file) should include something like the following:

<style>
.align-center {
    display: block;
    text-align: center;
    margin-top: 0.3em;
}
</style>

Post-production editing

If it is necesssary to make an adjustment to a formula in the final html file, it can be edited using the "data-tex" attribute for the image to make a new Tex expression with the backslash delimiters restored and the file run through the converter to make a new image. The program will not waste time re-processing the rest of the file because it only looks for maths expressions with backslash delimiters.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago