📜 ⬆️ ⬇️

PhpMathPublisher - Math Formulas in HTML

In one of the projects, it became necessary to use complex mathematical formulas in the text. The option of using formula editors like Microsoft Equation and then saving them as an image is not suitable, because you need to easily edit existing formulas.
The solution was found in the form of PhpMathPublisher .

image
PhpMathPublisher is a system for publishing mathematical formulas in HTML, using only PHP tools.
Each formula is converted to a PNG image by a script that returns the corresponding HTML code.
The solution is cross-browser, the end user is not required to install any add-ons or fonts.
The script requires the GD library and some fonts containing mathematical symbols (the fonts are included in the kit).
Here are some examples of formulas generated using PhpMathPublisher :
PhpMathPublisher
PhpMathPublisher
PhpMathPublisher

Using


1. Download the archive
2. Unpack the archive. The archive already contains all the necessary fonts, as well as examples and documentation.
To use mathematical expressions, we connect only one file:
include( "mathpublisher.php" );
* This source code was highlighted with Source Code Highlighter .

... and derive the formulas:
echo mathfilter($text,$size,$pathtoimg);

* This source code was highlighted with Source Code Highlighter .

Where:
$text - text with standard HTML tags and mathematical expressions enclosed in tags <m> ... </ m> (more details below);
$size - font size;
$pathtoimg - relative path to the directory for storing images.

The parser on the fly converts the expressions contained in the tags <m> ... </ m> into images with formulas and stores them in the image directory. The syntax of expressions is available in the documentation in the archive or online .
Example:
< m > pi=3/4 sqrt{3}+24 int{0}{1/4}{sqrt{xx^2}dx} </ m >

* This source code was highlighted with Source Code Highlighter .

Converted version:
PhpMathPublisher
')
There are PhpMathPublisher plugins for Wordpress:
http://wordpress.org/extend/plugins/wpmathpub/
http://wordpress.org/extend/plugins/wpmathpublisher/

The first post on Habré, please do not judge strictly :)

Source: https://habr.com/ru/post/45292/


All Articles