Skip to content
/ wikicloth Public
forked from nricciar/wikicloth

Ruby implementation of the MediaWiki markup language.

License

Notifications You must be signed in to change notification settings

grze/wikicloth

This branch is 52 commits behind nricciar/wikicloth:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

David RicciardiDavid Ricciardi
David Ricciardi
and
David Ricciardi
Sep 24, 2012
23c398f · Sep 24, 2012
Jun 27, 2011
Feb 14, 2012
Sep 24, 2012
Feb 8, 2012
Jul 21, 2010
Apr 22, 2012
Oct 7, 2011
Aug 11, 2011
Aug 11, 2011
Jul 21, 2010
Aug 13, 2011
Feb 13, 2012
Feb 9, 2012
Jul 21, 2010
Jan 30, 2011
Feb 10, 2012

Repository files navigation

WikiCloth

Ruby implementation of the MediaWiki markup language.

Supports

  • Variables, Templates {{ … }}
  • Links
    • External Links [ … ]
    • Internal Links, Images [[ … ]]
  • Wikimedia Markup
    • == Headings ==
    • Lists (*#;:)
    • bold ('''), italic ('') or both (''''')
    • Horizontal rule (——)
    • Tables
    • Table of Contents [__NOTOC__, __FORCETOC__, __TOC__]
  • <code>,<nowiki>,<pre> (disable wiki markup)
  • <ref> and <references/> support
  • html sanitization

For more information about the MediaWiki markup see http://www.mediawiki.org/wiki/Markup_spec

Install

  git clone git://github.com/nricciar/wikicloth.git
  cd wikicloth/
  rake install

Usage

  @wiki = WikiCloth::Parser.new({
    :data => "<nowiki>{{test}}</nowiki> ''Hello {{test}}!''\n",
    :params => { "test" => "World" } })

  @wiki.to_html => "<p>&#123;&#123;test&#125;&#125;  <i>Hello World!</i></p>"

Advanced Usage

Most features of WikiCloth can be overriden as needed…

  class WikiParser < WikiCloth::Parser

    url_for do |page|
      "javascript:alert('You clicked on: #{page}');"
    end

    link_attributes_for do |page|
      { :href => url_for(page) }
    end

    template do |template|
      "Hello {{{1}}}" if template == "hello"
    end

    external_link do |url,text|
      "<a href=\"#{url}\" target=\"_blank\" class=\"exlink\">#{text.blank? ? url : text}</a>"
    end

  end

  @wiki = WikiParser.new({ 
    :params => { "PAGENAME" => "Testing123" }, 
    :data => "{{hello|world}} From {{ PAGENAME }} -- [www.google.com]"; 
  })

  @wiki.to_html =>
  <p>
  Hello world From Testing123 -- <a href="http://www.google.com" target="_blank" class="exlink">http://www.google.com</a>
  </p>

About

Ruby implementation of the MediaWiki markup language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published