[cgi-wiki-dev] Multiple formatter support
Kate L Pugh
Wed, 10 Sep 2003 10:23:10 +0100
I'd like to be able to make wikis where the author of a node can
choose what wiki (or other) syntax to write in - using, for example, a
drop-down box on the edit screen.
This will allow you to do things like have documentation pages written
in POD, test suite pages written in plain text and rendered using a
simple formatter class that just puts <pre> around everything, and
discussion pages written in your favourite Wiki syntax.
There's an example of this at
Now, that's done in the OpenGuides layer - I haven't seen Jody's code
so I don't know quite how; I'm guessing that he's always calling
$relevant_formatter->format rather than $wiki->formatter.
I want to add this multiple formatter feature to CGI::Wiki::Kwiki and
so am wondering whether it should be explicitly supported by
CGI::Wiki, and if so, should this be done by changing the CGI::Wiki
API or by creating CGI::Wiki::Formatter::Multiple to handle it all.
The main tasks that a solution needs to accomplish are:
- when saving a node, store some metadata to indicate the required formatter
- when displaying a node, retrieve that metadata and use it to choose the
Changing the CGI::Wiki API would mean that CGI::Wiki was mandating the
behaviour of a particular metadata field, something it hasn't done up
to now and I'm not sure it should do.
Handling it via CGI::Wiki::Formatter::Multiple would mean that the
application code would be responsible for storing and retrieving the
formatter-type metadata. The wins in this case over just handling all
the multipleness in code would be:
- can just call $wiki->format instead of selecting the right
formatter class, instantiating and calling that
- things like allowed_tags only need to be supplied once, to
CGI::Wiki::Formatter::Multiple->new, rather than to each individual
formatter. (On the other hand, you might *want* to allow different
tags for the different types of pages.)