[dokuwiki] Re: Handler::status['section']

  • From: Michael Hamann <michael@xxxxxxxxxxxxxxxx>
  • To: dokuwiki <dokuwiki@xxxxxxxxxxxxx>
  • Date: Thu, 11 Aug 2011 23:25:59 +0200

Hi,

Excerpts from Guillaume Turri's message of 2011-08-11 15:33:11 +0200:
[...]
> To put it in a nutshell:
> Is it possible to tell the Handler that the current section should not be
> closed while in my plugin's mode (and what would be the proper way to do
> it)?

No, there is no such way afaik. The problem is that the HTML structure
is using pseudo tags as follows:

[section level 0 content]

<headline level1 />
<section level1>
[section level 1 content]
</section level 1>

<headline level2 />
<section level 2>
[section level 2 content]
</section level2>

etc.

This means that sections aren't nested but always completely closed on
every headline so you can't allow headlines in syntax that begins inside a
section. The only workaround I'm aware of is to close the section before
the plugin.

The include plugin faces a similar problem. The include plugin does
close the currently opened section at the beginning and opens it again
after the wrapper div of the include plugin[1]. In order to get the current
section level it is using an action part[2] that scans through the
instructions and adds the current section level to the include plugin
instructions. Inside the wrapper div the include plugin includes a
different page so it uses different sections there but you can of course
simply reopen previously opened section inside your plugin and close at
the end the section the close instruction is in and reopen that section
after the closing  wrapper div of your plugin.

As I think there are more plugins facing this problem maybe we could
make such things a bit easier, e.g. by providing the currently opened
section level as attribute in the handler and renderer (and no, this is
not the "lastlevel" attribute in the xhtml renderer as this one is only
set by non-empty headlines but also empty headlines trigger a new
section).

Btw. the header-syntax[3] doesn't do that differently, it simply closes the
last section when status['section'] is set and opens after it a new
section with the current level. This should also answer what
status['section'] is used for. Setting it to false simply prevents the
header-syntax from closing the current section, but it will most
probably produce invalid HTML. The problem why our plugins can't do
the same things is that the plugins don't know the current section
level for reopening it.

Michael

[1]:
https://github.com/dokufreaks/plugin-include/blob/master/helper.php#L412
[2]:
https://github.com/dokufreaks/plugin-include/blob/master/action.php#L61
[3]:
https://github.com/splitbrain/dokuwiki/blob/master/inc/parser/handler.php#L92
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: