Structuring the code of a wiki parsing engine

M

Michiel Sikma

Hello everybody. I'm kind of new to Python. I'm working on a simple
text parser that will allow me to transform a certain syntax into a
certain output. I find wikis interesting, so wiki to HTML parsing is
one of the things that I want to accomplish (I'm not actually writing
a whole wiki, that's complex, but I'm only trying to get basic text
conversion going on).

Presently, I'm thinking of putting the (simple, regexp-driven)
filters in a module called "parsers", and then make a "handlers"
module that allows for the actual transformation. So, for example,
one parser would be a separate class (WikiParser) which would have an
attribute called "emph" (emphasis) which is a string '\*\*(.+?)\*\*'.
Then a handler class (HTMLHandler) would have an attribute called
"emph" which is a string '<em>\\1</em>'. Then the regular expressions
would be generated via a chosen parser/handler combination. This to
make it easy to change things around later.

My question to you: is this the right way to go about it? My parser
doesn't really need to do all that much, but I would like for it to
be easily changeable by editing a single file.

Thanks for any help!

Greets,
Michiel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top