Coder Social home page Coder Social logo

wikicloth's Introduction

WikiCloth

Ruby implementation of the MediaWiki markup language.

Supports

  • Variables, Templates {{ … }}
  • Links
    • External Links [ … ]
    • Internal Links, Images [[ … ]]
  • 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 https://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>

wikicloth's People

Contributors

nricciar avatar emily avatar bdunagan avatar ktdreyer avatar chocolateboy avatar flavorjones avatar olleolleolle avatar benjaminplee avatar deardaniel avatar robolson avatar krinkle avatar technoweenie avatar andreas12345 avatar bartkamphorst avatar dee-see avatar qmx avatar raven24 avatar gjtorikian avatar pustomytnyk avatar zpvip avatar katafrakt avatar meshr-net avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.