From: Patrick Gundlach Date: 2005-10-25T02:07:01+09:00 Subject: TagTreeScanner help Hello out there, I am experimenting with TagTreeScanner from Gavin Kistner. Has anybody created a Wiki-markup parser for the mediawiki software? I have succeded for a few tags, but I am currently stuck with enumerations: * one *two * three ** threeone ** threetwo *four should be represented by sth. like
  1. one
  2. two
  3. three
    1. threeone
    2. threetwo
  4. four
This is what I have tried, but I have the feeling that is not the way to proceed here. I only get
around the string. -------------------------------------------------- #!/opt/ruby/1.8.2/bin/ruby require 'TagTreeScanner' class SimpleMarkup < TagTreeScanner @root_factory.allows_text = false @tag_genres[ :root ] = [ ] @tag_genres[ :root ] << TagFactory.new( :ol, :open_match => /(\*.+?)\n+(?=[^*])/m, :open_requires_bol => true, :setup => lambda{ |tag, scanner, tagtree| # Throw the contents I found into the tag # but remove leading whitespace tag << scanner[1] # [1].gsub( /\*/, '
  • ' ) }, :allows_text => true, :autoclose => :true, # no effect: (??) :allowed_genre => :list ) @tag_genres[ :list ] = [ ] @tag_genres[ :list ] << TagFactory.new( :li, :open_match => /\*/, :close_match => /\n/, :open_requires_bol => true, :allows_text => true ) end sample = <