1<?php
2/**
3 * Creole Plugin, emptyline component: notifies
4 * other creole syntax components that an empty line was detected.
5 *
6 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     LarsDW223
8 */
9
10/**
11 * All DokuWiki plugins to extend the parser/rendering mechanism
12 * need to inherit from this class
13 */
14class syntax_plugin_creole_emptyline extends DokuWiki_Syntax_Plugin {
15    var $eventhandler = NULL;
16
17    function getInfo() {
18        return array(
19                'author' => 'Gina Häußge, Michael Klier, Christopher Smith',
20                'email'  => 'dokuwiki@chimeric.de',
21                'date'   => '2015-08-30',
22                'name'   => 'Creole Plugin (emptyline component)',
23                'desc'   => 'Provide a notification if an empty line is detected.',
24                'url'    => 'http://wiki.splitbrain.org/plugin:creole',
25                );
26    }
27
28    function getType() { return 'substition'; }
29    function getPType() { return 'block'; }
30    function getSort() { return 99; }
31
32    function connectTo($mode) {
33        $this->Lexer->addSpecialPattern(
34                '\n(?=\n)',
35                $mode,
36                'plugin_creole_emptyline'
37                );
38    }
39
40    /**
41     * Constructor.
42     */
43    public function __construct() {
44        $this->eventhandler = plugin_load('helper', 'creole_eventhandler');
45    }
46
47    function handle($match, $state, $pos, Doku_Handler $handler) {
48        if ( $state == DOKU_LEXER_SPECIAL  ) {
49            $this->eventhandler->notifyEvent('found', 'emptyline', NULL, $pos, $match, $handler);
50            return true;
51        }
52        return false;
53    }
54
55    function render($mode, Doku_Renderer $renderer, $data) {
56        /*if($mode == 'xhtml') {
57            if ($data) {
58                if ( $this->getConf('linebreak') == 'Linebreak' ) {
59                    $renderer->doc .= "<br /><br />";
60                } else {
61                    $renderer->doc .= " ";
62                }
63            }
64            return true;
65        }*/
66        return false;
67    }
68}
69// vim:ts=4:sw=4:et:enc=utf-8:
70