Public Member Functions | |
| __construct ($output_dir=null, $tmp_dir=null) | |
| getFormulaURL ($latex_formula) | |
| getPreamble () | |
| render ($latex_formula, $inline=false) | |
| clean ($tmp_filename) | |
| isCleanLatex ($latex) | |
| getOutputFile ($latex, $inline=false) | |
Public Attributes | |
| $tmp_dir = '/tmp' | |
| $output_dir = '/tmp' | |
| $encoding = 'utf-8' | |
| $fragment = '' | |
| $latex_path = '/usr/bin/latex' | |
| $dvipng_path = '/usr/bin/dvipng' | |
| $resolution = '120' | |
| $bg_color = 'ffffff' | |
| $debug = false | |
| $tags_blacklist | |
| $error_code = 0 | |
| $error_msg = '' | |
Based on code by: Benjamin Zeiss Copyright (C) 2003 Benjamin Zeiss <zeiss@math.uni-goettingen.de> http://www.mayer.dial.pipex.com/tex.htm Kjell Magne Fauske http://www.fauskes.net/nb/htmleqII/
Example usage:
$latex = new Pluf_Text_Latex_Equation(); if (true === $latex->render('e = mc^2')) { $png_file = $latex->output_file; $png_full_path = $latex->output_path; } else { $error = $latex->error_code; $msg = $latex->error_msg; }
Note that the class is not using exception to return the errors, that way you can easily grab the error and depending on the error code/message generate a special .png file to display.
| Pluf_Text_Latex_Equation::__construct | ( | $ | output_dir = null, |
|
| $ | tmp_dir = null | |||
| ) |
Initializes the class
| string | Output directory (null) | |
| string | Temp directory (null) |
| Pluf_Text_Latex_Equation::getFormulaURL | ( | $ | latex_formula | ) |
Tries to match the LaTeX Formula given as argument against the formula cache. If the picture has not been rendered before, it'll try to render the formula and drop it in the picture cache directory.
| string | formula in LaTeX format |
| Pluf_Text_Latex_Equation::getPreamble | ( | ) |
Get the Latex preamble.
You can overwrite this function if you want.
| Pluf_Text_Latex_Equation::render | ( | $ | latex_formula, | |
| $ | inline = false | |||
| ) |
Renders a LaTeX formula by the using the following method:
| string | LaTeX formula | |
| bool | Render an inline formulat (false) |
| Pluf_Text_Latex_Equation::clean | ( | $ | tmp_filename | ) |
Cleans the temporary directory
| Pluf_Text_Latex_Equation::isCleanLatex | ( | $ | latex | ) |
Check if the latex code is clean.
| string | Latex code. |
| Pluf_Text_Latex_Equation::getOutputFile | ( | $ | latex, | |
| $ | inline = false | |||
| ) |
Get the output file based on the latex fragment.
| string | Latex. | |
| bool | Is the equation an inline equation (false). | |
| string | Output file with extension without directory. |
| Pluf_Text_Latex_Equation::$tmp_dir = '/tmp' |
| Pluf_Text_Latex_Equation::$output_dir = '/tmp' |
| Pluf_Text_Latex_Equation::$encoding = 'utf-8' |
| Pluf_Text_Latex_Equation::$fragment = '' |
| Pluf_Text_Latex_Equation::$latex_path = '/usr/bin/latex' |
| Pluf_Text_Latex_Equation::$dvipng_path = '/usr/bin/dvipng' |
| Pluf_Text_Latex_Equation::$resolution = '120' |
| Pluf_Text_Latex_Equation::$bg_color = 'ffffff' |
| Pluf_Text_Latex_Equation::$debug = false |
| Pluf_Text_Latex_Equation::$tags_blacklist |
Initial value:
array(
'include', 'def', 'command', 'loop', 'repeat', 'open', 'toks', 'output',
'input', 'catcode', 'name', '^^', '\\every', '\\errhelp',
'\\errorstopmode', '\\scrollmode', '\\nonstopmode', '\\batchmode',
'\\read', '\\write', 'csname', '\\newhelp', '\\uppercase', '\\lowercase',
'\\relax', '\\aftergroup', '\\afterassignment', '\\expandafter',
'\\noexpand', '\\special')
this most certainly needs to be extended. in the long term it is planned to use a positive list for more security. this is hopefully enough for now. i'd be glad to receive more bad tags !
| Pluf_Text_Latex_Equation::$error_code = 0 |
| Pluf_Text_Latex_Equation::$error_msg = '' |