<?php
/**
 * LaTeX Equation Syntax
 * 
 * Primary Author: Wizardry and Steamworks <wizardry.steamworks@outlook.com>
 * @license GPL 2
 */
require_once(realpath(dirname(__FILE__).'/../latexinc.php'));

class syntax_plugin_latexwas_equation extends syntax_plugin_latexwas_common {
    public function connectTo($mode) {
        $this->Lexer->addEntryPattern('\x5Cbegin\{equation\}(?=.*\x5Cend\{equation\})', $mode, 'plugin_latexwas_equation');
    }

    public function postConnect() {
        $this->Lexer->addExitPattern('\x5Cend\{equation\}', 'plugin_latexwas_equation');
    }

    public function handle($match, $state, $pos, Doku_Handler $handler) {
        if ($state !== DOKU_LEXER_UNMATCHED) return [$match, $state, NULL];
        return ["\\begin{equation}" . $match . "\\end{equation}", $state, 'class' => "latex_displayed", 'title' => "Equation"];
    }
}
