Steve Sanbeg wrote:
On Wed, 21 Nov 2007 12:54:24 +1100, Tim Starling wrote:
LST can be reimplemented by using the DOM representation of the transcluded template to scan for <section> tags. I'm in the process of doing this.
OK, thanks. I figured that would fit in somewhere. I've merged the cache code I was working on into the Parser, since it looked pretty obvious where that should go. Then the DOM representation should take care of finding the sections, offsetting the headings, and caching?
Parser::getTemplateDom() will return a cached DOMDocument for the desired page. Then LST will have to traverse the tree, find the <ext> nodes, parse the attributes in a backwards-compatible way, and then put together the output for the desired section by calling $frame->expand() on the relevant nodes.
<section> tags occurring anywhere other than the top level, e.g.
{{some template | <section start=foo/>}} <section end=foo/>
is a problem that is most easily dealt with by ignoring extension tags that aren't children of the root node. Perhaps the section tag could return an error in this case, to help the user identify the problem.
The potentially common case:
== Heading text <section start=foo/> ==
could perhaps be special-cased in a DWIM kind of way.
-- Tim Starling