2017 © Pedro Peláez
 

library phpmathpublisher

phpMathPublisher fork. Rewritten in php5.3. Added PSR-4 support

image

ftes/phpmathpublisher

phpMathPublisher fork. Rewritten in php5.3. Added PSR-4 support

  • Wednesday, February 14, 2018
  • by ftes
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

phpMathPublisher

phpMathPublisher fork, hosted on github to allow seamless integration in composer-based php apps. Packagist package is auto-updated via service hook., (*1)

Authors

  • Original version Pascal Brachet, http://www.xm1math.net/phpmathpublisher/
  • php5.3 rewrite Peter Vasilevsky a.k.a. Tux-oid, http://rulinux.net
  • psr-4 restructuring Andreas Gohr, https://www.splitbrain.org

How to use

  1. Configure settings via the constructor new PhpMathPublisher($imgpath, $webpath, $size), where
    • $imgpath is the path where the png files should be stored,
    • $webpath is the path under which the png files are accessable via the web server and
    • size is the text size to be used when generating these images
  2. Call one of the interface methods on your PhpMathPublisher object
    • mathImage($text): Creates the formula image (if the image is not in the cache) and returns the <img src=...></img> html code
    • mathImagePath($text): Creates the formula image (if the image is not in the cache) and returns the absolute path on the file system to the image
    • mathImageBinary($text): Creates the formula image and returns the binary PNG contents (warning: does not use the file cache, thus inefficient)
    • mathFilter($text): Replaces all <m> tags in $text with <img> tags by using mathImage()
    • renderImage($text, $file): Creates an image for the given formula at the given place

Example

(new PhpMathPublisher('../dir/to/img/', 'img/', 12))->mathFilter('A math formula : <m>f(x)=sqrt{x}</m>') will return:, (*2)

'A math formula : <img src=\"img/math_988.5_903b2b36fc716cfb87ff76a65911a6f0.png\" style=\"vertical-align:-11.5px; display: inline-block ;\" alt=\"f(x)=sqrt{x}\" title=\"f(x)=sqrt{x}\">'

The image corresponding to a formula is created only once. Then the image is stocked into the image directories. The first time that mathfilter is called, the images corresponding to the formulas are created, but the next times mathfilter will only return the html code., (*3)

NOTE: if the free latex fonts furnished with this script don't work well (very tiny formulas - that's could happened with some GD configurations), you should try to use the bakoma versions of these fonts (downloadable here), (*4)

The Versions

14/02 2018

dev-master

9999999-dev https://github.com/ftes/phpmathpublisher

phpMathPublisher fork. Rewritten in php5.3. Added PSR-4 support

  Sources   Download

GPLv2 GPL-3.0-or-later

The Requires

  • php >=5.3.3

 

by Fredrik Teschke

math mathematics phpmathpublisher