[dokuwiki] Re: Allow header in a syntax plugin

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 10 Oct 2009 16:16:12 +0100


On 10 Oct 2009, at 14:52, Guillaume Turri wrote:


Does the third line means that anyway headers will only be allowed if we aren't in a specific mode, and thus, won't be allowed in a syntax plugin ?
If I'm wrong, how could I manage to allow such headers ?

Headers are a special case, they also affect the table of contents and editable sections of the wiki page. I don't believe you can include dokuwiki's own header handling within your own syntax plugin.

You can, however, instigate your own headers with the same syntax within your syntax mode. There are two ways to do this.

1. Use addPattern to add the same header regex and handle headers within the same syntax plugin.

2. Add a second syntax plugin (or plugin component) to handle the same header pattern. For safety, implement the "accepts" method and only respond true when the requested mode is that for your main syntax plugin.

Syntax plugins don't usually have to handle "accepts", the parent plugin class takes care of it based on the value returned getAllowedTypes().

At this point your headers won't be in the TOC and you won't have any edit buttons. Adding to TOC should be pretty straight forward, reviewing the DokuWiki header code should show you how to do that. Getting your own editable sections will be more complex. A review of DokuWiki's code should give you some ideas. :)

- Chris
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: