I'm not sure if this is the right place to discuss plugin development issues? If not I apologise for the noise and would appreciate a hint on where this discussion would be more appropriate. Thx.!
I am new to DokuWiki plugin development so I'm probably missing something here ;-)
I am developing a plugin which has two variants: inline and block. The syntax is <mytag>…</mytag>
for the inline variant and <MYTAG>…</MYTAG>
for the block variant.
The inline variant inserts HTML directly at the point where tags are placed. This would be similar to a <span>
element. And it works fine.
The block variant is supposed to place the generated HTML into a block element, such as <p>
or <div>
. However when my render() method outputs e.g. <p>Something</p>
the actual output on the page is: <p><p>Something</p></p>
. So DokuWiki apparently already opens a <p>
element. Browsers tend to synthesise missing tags to avoid non-standard HTML so that the apparent page source ends up as <p></p><p>Something</p><p></p>
. Optically this does not matter but I'd like to avoid this if possible. Nested <p>
elements are not valid HTML.
So how can I avoid the opening <p>
generated by DW as well as the additional closing </p>
?
Note that this might get complicated if there is any inline content before my tag, such as Label:<MYTAG>…
. In that case I would need to close the DW-generated <p>
(which would then include <p>Label:</p>
) and then insert my block element. But how can my plugin know about this situation?
Example:
Let's say my tag name is MYTAG
. So <MYTAG>Something</MYTAG>
should produce the block element.
If the DW page source is:
===== Example A =====
<MYTAG>Something</MYTAG>
===== Example B =====
Label:<MYTAG>Something</MYTAG>
Currently this produces something like:
<h3 class="sectionedit1" id="example_a">Example A</h3>
<div class="level1">
<p><p>Something</p></p>
</div>
<div class="secedit editbutton_section editbutton_1">…</div>
<h3 class="sectionedit1" id="example_b">Example B</h3>
<div class="level1">
<p> Label: <p>Something</p></p>
</div>
<div class="secedit editbutton_section editbutton_2">…</div>
I would want the output to be:
<h3 class="sectionedit1" id="example_a">Example A</h3>
<div class="level1">
<p>Something</p>
</div>
<div class="secedit editbutton_section editbutton_1">…</div>
<h3 class="sectionedit1" id="example_b">Example B</h3>
<div class="level1">
<p> Label: </p><p>Something</p>
</div>
<div class="secedit editbutton_section editbutton_2">…</div>
Thanks!
fiwswe