1<?php
2/*
3 * Codespans enclosed with two backticks: ``...``
4 */
5
6if(!defined('DOKU_INC')) die();
7if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
8require_once(DOKU_PLUGIN.'syntax.php');
9
10class syntax_plugin_markdowku_codespans2 extends DokuWiki_Syntax_Plugin {
11
12    function getType()  { return 'formatting'; }
13    function getPType() { return 'normal'; }
14    function getSort()  { return 98; }
15
16    function connectTo($mode) {
17        $this->Lexer->addSpecialPattern(
18            '(?<!`)``(?!`).+?(?<!`)``(?!`)',
19            $mode,
20            'plugin_markdowku_codespans2');
21    }
22
23    function handle($match, $state, $pos, Doku_Handler $handler) {
24        return array($match);
25    }
26
27    function render($mode, Doku_Renderer $renderer, $data) {
28        $renderer->monospace_open();
29        $renderer->cdata(substr($data[0], 2, -2));
30        $renderer->monospace_close();
31        return true;
32    }
33}
34//Setup VIM: ex: et ts=4 enc=utf-8 :
35