Skip to content
forked from AboutUs/kiwi

Yet Another Peg WikiText Parser

License

Unknown, BSD-3-Clause licenses found

Licenses found

Unknown
LICENSE
BSD-3-Clause
bstrlib-license.txt
Notifications You must be signed in to change notification settings

giuliopaci/kiwi

 
 

Repository files navigation

Kiwi

Kiwi is a C implementation of the vast majority of MediaWiki's wikitext syntax. Nevertheless Kiwi fails to pass 90% of the official MediaWiki parser tests (using a relaxed test, where some differences are ignored) as most corner cases are treated differently by the two parsers. It currently takes input on stdin and presents output on stdout, and there is a Ruby FFI module for direct library use as well. The major advantages of this implementation are intended to be speed and memory footprint.

At the moment a 100 line wikitext file with fairly complex markup can be parsed in 5-6ms on a one year old Apple MacBook Pro.

See it Live

Kiwi is running on the web at drasticcode.com. Check it out there for a better list of capabilities.

Simplest Ruby Example with Templates

require "yapwtp"

parser = WikiParser.new

# Open the requested file, parse, capture text and templates
wikitext = parser.html_from_file("cnn.com.wt")
templates = parser.templates

templates.each do |template|
  template_file = File.join("templates", template[:name]) 
  if File.exist? template_file
    wikitext.gsub! /#{template[:replace_tag]}/, parser.html_from_file(template_file)
  end
end
puts wikitext

About

Yet Another Peg WikiText Parser

Resources

License

Unknown, BSD-3-Clause licenses found

Licenses found

Unknown
LICENSE
BSD-3-Clause
bstrlib-license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 78.6%
  • Ruby 20.7%
  • C++ 0.7%