1<?php
2/*
3 * Unescape escaped backslash. \\\\ -> \
4 * This is in a separate class as it needs a higher priority than the other
5 * escapes.
6 */
7
8if(!defined('DOKU_INC')) die();
9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10require_once(DOKU_PLUGIN.'syntax.php');
11
12class syntax_plugin_markdowku_escapespecialchars extends DokuWiki_Syntax_Plugin {
13
14    function getType()  { return 'substition'; }
15    function getPType() { return 'normal'; }
16    function getSort()  { return 61; }
17
18    function connectTo($mode) {
19        $this->Lexer->addSpecialPattern(
20            '(?<!\\\\)\\\\`',
21            $mode,
22            'plugin_markdowku_escapespecialchars');
23        $this->Lexer->addSpecialPattern(
24            '(?<!\\\\)\\\\\*',
25            $mode,
26            'plugin_markdowku_escapespecialchars');
27        $this->Lexer->addSpecialPattern(
28            '(?<!\\\\)\\\\_',
29            $mode,
30            'plugin_markdowku_escapespecialchars');
31        $this->Lexer->addSpecialPattern(
32            '(?<!\\\\)\\\\\{',
33            $mode,
34            'plugin_markdowku_escapespecialchars');
35        $this->Lexer->addSpecialPattern(
36            '(?<!\\\\)\\\\\}',
37            $mode,
38            'plugin_markdowku_escapespecialchars');
39        $this->Lexer->addSpecialPattern(
40            '(?<!\\\\)\\\\\[',
41            $mode,
42            'plugin_markdowku_escapespecialchars');
43        $this->Lexer->addSpecialPattern(
44            '(?<!\\\\)\\\\\]',
45            $mode,
46            'plugin_markdowku_escapespecialchars');
47        $this->Lexer->addSpecialPattern(
48            '(?<!\\\\)\\\\\(',
49            $mode,
50            'plugin_markdowku_escapespecialchars');
51        $this->Lexer->addSpecialPattern(
52            '(?<!\\\\)\\\\\)',
53            $mode,
54            'plugin_markdowku_escapespecialchars');
55        $this->Lexer->addSpecialPattern(
56            '(?<!\\\\)\\\\>',
57            $mode,
58            'plugin_markdowku_escapespecialchars');
59        $this->Lexer->addSpecialPattern(
60            '(?<!\\\\)\\\\\#',
61            $mode,
62            'plugin_markdowku_escapespecialchars');
63        $this->Lexer->addSpecialPattern(
64            '(?<!\\\\)\\\\\+',
65            $mode,
66            'plugin_markdowku_escapespecialchars');
67        $this->Lexer->addSpecialPattern(
68            '(?<!\\\\)\\\\\-',
69            $mode,
70            'plugin_markdowku_escapespecialchars');
71        $this->Lexer->addSpecialPattern(
72            '(?<!\\\\)\\\\\-',
73            $mode,
74            'plugin_markdowku_escapespecialchars');
75        $this->Lexer->addSpecialPattern(
76            '(?<!\\\\)\\\\\.',
77            $mode,
78            'plugin_markdowku_escapespecialchars');
79        $this->Lexer->addSpecialPattern(
80            '(?<!\\\\)\\\\!',
81            $mode,
82            'plugin_markdowku_escapespecialchars');
83    }
84
85    function handle($match, $state, $pos, Doku_Handler $handler) {
86        return array($state, $match);
87    }
88
89    function render($mode, Doku_Renderer $renderer, $data) {
90		$renderer->doc .= substr($data[1], -1);
91        return true;
92    }
93}
94//Setup VIM: ex: et ts=4 enc=utf-8 :
95