zim-wiki team mailing list archive
Mailing list archive
Re: new wiki syntax: better way to implement in Zim ?
On Sun, Jan 23, 2011 at 4:29 PM, Juancarlo Añez <apalala@xxxxxxxxx> wrote:
> If Jaap could refactor the code so Wiki parsers were pluggable and had a
> defined pluging API, some of us would be really happy.
> As I understand the current state of affairs, the spec for the output of a
> wiki parser is the source code for current parser, of which Japp talks of as
I would like to nuance that statement a bit. The parser is hacked in
the sense that it doesn't follow a specific standard design. However
the interface is quite clear and separated from the parser
We use the xml.etree module to create XML object structures which are
used internally to represent text formatting. Agreed that detailed
documentation is lacking a bit but have a look at
HACKING/Parse_Tree.txt in the source package. Or look at the unit
tests for the parser, where this intermediate XML is used extensively.
There is a builder class in zim/formats/__init__.py that can help to
construct the XML object tree.
As for being able to plug in new formats. Currently the the only way
is to install a new module in the zim/formats namespace. The
get_format() module will then pick it up. If there is a need to add
formats from other namespaces we can easily add a method for plugins
to register additional modules.