By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

Structuring the code of a wiki parsing engine

P: n/a
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!


May 19 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.