. // }}} /** * LaTeX note support for GNU social * * @package GNUsocial * @category Plugin * * @author Phablulo * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\LatexNotes; use App\Core\Event; use App\Core\Modules\Plugin; use EventResult; use PhpLatex_Parser; use PhpLatex_Renderer_Html; class LatexNotes extends Plugin { public function onPostingAvailableContentTypes(array &$types): EventResult { $types['LaTeX'] = 'application/x-latex'; return Event::next; } public function onRenderNoteContent($content, $content_type, &$rendered): EventResult { if ($content_type !== 'application/x-latex') { return Event::next; } // https://github.com/xemlock/php-latex $parser = new PhpLatex_Parser(); $parsedTree = $parser->parse($content); $htmlRenderer = new PhpLatex_Renderer_Html(); $rendered = $htmlRenderer->render($parsedTree); return Event::stop; } }