467,926 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Structuring the code of a wiki parsing engine

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

May 19 '07 #1
  • viewed: 835
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by tm | last post: by
2 posts views Thread by Eric | last post: by
2 posts views Thread by Kenneth McDonald | last post: by
44 posts views Thread by john bailo | last post: by
1 post views Thread by Michael Schuerig | last post: by
1 post views Thread by loguser | last post: by
3 posts views Thread by piotr maliŮski | last post: by
5 posts views Thread by Alexey Smirnov | last post: by
25 posts views Thread by Jon Slaughter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.