1<?php
2/**
3 * LaTeX Equation Syntax
4 *
5 * Primary Author: Wizardry and Steamworks <wizardry.steamworks@outlook.com>
6 * @license GPL 2
7 */
8require_once(realpath(dirname(__FILE__).'/../latexinc.php'));
9
10class syntax_plugin_latexwas_equation extends syntax_plugin_latexwas_common {
11    public function connectTo($mode) {
12        $this->Lexer->addEntryPattern('\x5Cbegin\{equation\}(?=.*\x5Cend\{equation\})', $mode, 'plugin_latexwas_equation');
13    }
14
15    public function postConnect() {
16        $this->Lexer->addExitPattern('\x5Cend\{equation\}', 'plugin_latexwas_equation');
17    }
18
19    public function handle($match, $state, $pos, Doku_Handler $handler) {
20        if ($state !== DOKU_LEXER_UNMATCHED) return [$match, $state, NULL];
21        return ["\\begin{equation}" . $match . "\\end{equation}", $state, 'class' => "latex_displayed", 'title' => "Equation"];
22    }
23}
24