R
Randy Kramer
I have the need to translate several megabytes of TWiki marked up text to
HTML. In fact, it may not even be a one time thing--I'm planning to build a
wiki like thing, and will probably keep TWiki markup as the native language
for storage. Over time, I may extend the TWiki markup syntax.
(Aside: I'm aware that Ruby has two other markup languages sometimes used for
wikis (Red Cloth (?) and Text <something>?)--I may someday support those as
well, but I'm not immediately interested in converting the megabytes of data
I have and learning a different markup language.)
My impression is that some or many wikis (this is my impression of TWiki)
don't use a "real parser" (like YACC or whatever), but instead simply search
and replace in the text using (many) Regular Expressions. Conceptually, that
seems an easy approach (less learning on my part, but probably tedious
creation of many REs (or borrowing from TWiki's Perl).
I've never used a parser, and am not really that familiar with them, but I'm
wondering what the tradeoffs might be. I've heard that a parser may be
easier to modify to extend the syntax. (But, I have a feeling that the TWiki
markup language might not be "regular" enough to be parsed by something like
YACC.):
* If I did create the proper grammar rules, would parsing using something
like YACC be faster than a bunch of RE replacements?
* Any recommendations for a parser in Ruby? I think there are a couple,
I've been doing some Googling / reading and have come across references to
parse.rb and (iirc) something called Coco (??).
* Anybody know the approach followed by existing Ruby wikis like Instiki,
Ruwiki, etc.?
Other comments, hints, suggestions?
Randy Kramer
HTML. In fact, it may not even be a one time thing--I'm planning to build a
wiki like thing, and will probably keep TWiki markup as the native language
for storage. Over time, I may extend the TWiki markup syntax.
(Aside: I'm aware that Ruby has two other markup languages sometimes used for
wikis (Red Cloth (?) and Text <something>?)--I may someday support those as
well, but I'm not immediately interested in converting the megabytes of data
I have and learning a different markup language.)
My impression is that some or many wikis (this is my impression of TWiki)
don't use a "real parser" (like YACC or whatever), but instead simply search
and replace in the text using (many) Regular Expressions. Conceptually, that
seems an easy approach (less learning on my part, but probably tedious
creation of many REs (or borrowing from TWiki's Perl).
I've never used a parser, and am not really that familiar with them, but I'm
wondering what the tradeoffs might be. I've heard that a parser may be
easier to modify to extend the syntax. (But, I have a feeling that the TWiki
markup language might not be "regular" enough to be parsed by something like
YACC.):
* If I did create the proper grammar rules, would parsing using something
like YACC be faster than a bunch of RE replacements?
* Any recommendations for a parser in Ruby? I think there are a couple,
I've been doing some Googling / reading and have come across references to
parse.rb and (iirc) something called Coco (??).
* Anybody know the approach followed by existing Ruby wikis like Instiki,
Ruwiki, etc.?
Other comments, hints, suggestions?
Randy Kramer