Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby implementation of the MediaWiki markup language.
Ruby
tree: 9be5a3dc90

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
sample_documents
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
init.rb
install.rb
run_tests.rb
uninstall.rb
wikicloth.gemspec

README

Ruby implementation of the MediaWiki markup language.

Supports
---------------------------------------------------

    * Variables, Templates {{ ... }}
    * Links
          o External Links [ ... ]
          o Internal Links, Images [[ ... ]]
                + (see also pipe trick) 
    * Wikimedia Markup
          o == Headings ==
          o Lists (*#;:)
          o bold ('''), italic ('') or both (''''')
          o Horizontal rule (----)
          o Tables 
          o Table of Contents [__NOTOC__, __FORCETOC__, __TOC__]
    * <code>,<nowiki>,<pre> (disable wiki markup)
          o space at the beginning of a line (<pre>) 
    * <ref> and <references/> support
    * html sanitization 

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>
Something went wrong with that request. Please try again.