Description

This is a meta-bug, but this way the Issue will get some visibility.

Note that the TOC macro is closely related to the include macro and that both are sharing code, copy&pasted.

The Include/TOC macro is a stale mess, that nobody wants to touch. It breaks every aspect of the moinmoin plugin architecture and has numerous known bugs that noone is fixing. It needs to be re-implemented.

Plan

Write a filter-parser

This would take two extra argument, from and to, which would be run against the raw text. It wouldn't differentiate the content type of the raw text at this point, just run the regexps until it finds the section between the from and to. It would copy that part in to a new string which I'll called filtered-raw-text.

After it has the filtered-raw-text it would prepend any prosessing intructions from the original raw page in to it. It would then pass it along for the regular parsing and formatting to take place.

Write the new Include-macro

The include macro would use the filter-parser to parse what is to be included. It would also pass along its own formatter in the Page object, so that the existing formatter instance would be used.

Write a formatter that just collects headings

The include and the TOC macro can use it generate the TOC.

Let the formatter generate ids for the topics

Currently, there is id generation code in the both macros. ID's are necessary to have jump anchors in the HTML. The formatter will generate the ID of every heading and return it via a method call.

Other ideas

Just some vague ideas to keep in mind. Doesn't need to be done all at once, though.

Questions

Current status

There is now an Insert-macro in the docbook-branch. This macro can live alongside the Include macro. It does basically what the old Include macro did, but the code is a bit cleaner, and it uses the current formatter, instead of instanciating a new one. The code should also be quite a bit cleaner and easier to understand. It doesn't use an external filter parser, instead it simply does it it self.

Missing features compared to the Include macros documentation:

Related bugs

Related feature requests


CategoryMoinMoinBug CategoryForMoin2

MoinMoin: MoinMoinBugs/ReImplementCleanerIncludeMacro (last edited 2010-01-12 14:16:00 by PascalVolk)