[dokuwiki] Re: How to number headlines ?

  • From: Ben Coburn <btcoburn@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 6 Apr 2006 14:57:39 -0700


On Apr 5, 2006, at 4:20 PM, Chris Smith wrote:

Chris Smith wrote:
It needs modifications to parts of the parser to work properly.
(1) Changes to header / section handling. I reckon they are improvements over the current methods so I'll package them up in a patch for Andi to look at.

Quick question before I do this.

At present, p_get_first_heading() (inc/parserutils.php) gets the first heading information by searching the document for the first header instruction. This works fine if your headers come from the dokuwiki native heading handler, but fails if headings are provided by some other mechanism.

Its also potentially inefficient as it needs to search the instruction list for a page until it find that first heading.

How about:
(1) adding a new piece of meta data, meta['first_heading']. If the value is empty, the native header syntax will fill that with the first heading it comes across. Any alternate method of handling headings can do the same. Then as long as everything behaves well, there will be no clashes and the first heading can be set by anything.


(2) the first heading information gets added as the first instruction in the list by the _finalise handler. This would guarantee that the first heading information is quickly accessible in every document.

Taking this a step further, could all the page meta data get added to the first instruction in the page. This opens up the possibility for native syntax modes and plugins to add page settings information in a controlled manner that could be used by other parts of dokuwiki simply by reading the first instruction.[1]


How about adding all of the heading information to the "meta" data on the front of the instruction list? Currently, rendering the subsection edit buttons in any other location (or with other semantics) requires information the renderer has not yet read in from the instruction list.


I propose that this meta-information include the list of headings (in order) with their starting position ($pos), depth, and (optionally) the heading text. This would allow the renderer to produce section edit button in both a flexible and efficient manner. I imagine it might also help with the TOC.

Regards, Ben Coburn


------------------- silicodon.net -------------------

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

Other related posts: