<?php
require_once(realpath(dirname(__FILE__).'/../latexinc.php'));

class syntax_plugin_latexwas_dollar extends syntax_plugin_latexwas_common {
    public function connectTo($mode) {
        $this->Lexer->addEntryPattern('\$(?=.*\$)', $mode, 'plugin_latexwas_dollar');
    }

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

    public function handle($match, $state, $pos, Doku_Handler $handler) {
        if($state !== DOKU_LEXER_UNMATCHED) return [$match, $state, NULL];
        return ["$" . $match . "$", $state, 'class' => "latex_inline", 'title' => "Math"];
    }
}
