1<?php
2/*
3 * Bold text enclosed in asterisks: **...**
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_boldasterisk extends DokuWiki_Syntax_Plugin {
11
12    function getType()  { return 'formatting'; }
13    function getPType() { return 'normal'; }
14    function getSort()  { return 69; }
15    function getAllowedTypes()  { return array('formatting', 'substition'); }
16
17    function connectTo($mode) {
18        $this->Lexer->addEntryPattern(
19            '(?<![\\\\*])\*\*(?![ ])(?=(?:(?!\n\n).)+?[^\\\\ ]\*\*)',
20            $mode,
21            'plugin_markdowku_boldasterisk');
22    }
23
24    function postConnect() {
25        $this->Lexer->addExitPattern(
26            '(?<![\\\\ ])\*\*',
27            'plugin_markdowku_boldasterisk');
28    }
29
30    function handle($match, $state, $pos, Doku_Handler $handler) {
31        return array($state, $match);
32    }
33
34    function render($mode, Doku_Renderer $renderer, $data) {
35        if ($data[0] == DOKU_LEXER_ENTER)
36            $renderer->strong_open();
37        elseif ($data[0] == DOKU_LEXER_EXIT)
38            $renderer->strong_close();
39        else
40            $renderer->cdata($data[1]);
41
42        return true;
43    }
44}
45//Setup VIM: ex: et ts=4 enc=utf-8 :
46