1<?php
2
3
4require_once(__DIR__ . '/../vendor/autoload.php');
5
6use ComboStrap\BreadcrumbTag;
7use ComboStrap\HrTag;
8use ComboStrap\PluginUtility;
9use ComboStrap\XmlTagProcessing;
10
11
12/**
13 * The empty pattern / void element
14 * (inline)
15 */
16class syntax_plugin_combo_xmlblockemptytag extends DokuWiki_Syntax_Plugin
17{
18
19    // should be the same than the last name of the class name
20    const TAG = "xmlblockemptytag";
21
22    private static function getEmptyBlockTag(): array
23    {
24        return [HrTag::TAG];
25    }
26
27    function getType(): string
28    {
29        return 'substition';
30    }
31
32    /**
33     * How Dokuwiki will add P element
34     *
35     *  * 'normal' - Inline
36     *  * 'block' - Block (dokuwiki does not create p inside)
37     *  * 'stack' - Block (dokuwiki creates p inside)
38     *
39     * @see DokuWiki_Syntax_Plugin::getPType()
40     */
41    function getPType(): string
42    {
43        /**
44         * Empty tag may be also block (ie Navigational {@link BreadcrumbTag} for instance
45         */
46        return 'block';
47    }
48
49    function getAllowedTypes(): array
50    {
51        return array();
52    }
53
54    function getSort(): int
55    {
56        // should be before all container tag
57        return 200;
58    }
59
60
61    function connectTo($mode)
62    {
63
64        foreach(self::getEmptyBlockTag() as $tag) {
65            $pattern = PluginUtility::getEmptyTagPattern($tag);
66            $this->Lexer->addSpecialPattern($pattern, $mode, PluginUtility::getModeFromTag($this->getPluginComponent()));
67        }
68
69    }
70
71    function handle($match, $state, $pos, Doku_Handler $handler): array
72    {
73        return XmlTagProcessing::handleStaticEmptyTag($match, $state, $pos, $handler, $this);
74    }
75
76    /**
77     * Render the output
78     * @param string $format
79     * @param Doku_Renderer $renderer
80     * @param array $data - what the function handle() return'ed
81     * @return boolean - rendered correctly? (however, returned value is not used at the moment)
82     * @see DokuWiki_Syntax_Plugin::render()
83     */
84    function render($format, Doku_Renderer $renderer, $data): bool
85    {
86
87        return XmlTagProcessing::renderStaticEmptyTag($format, $renderer, $data, $this);
88    }
89
90
91}
92
93