Giter Site home page Giter Site logo

tisba / wikicloth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nricciar/wikicloth

1.0 3.0 1.0 632 KB

Ruby implementation of the MediaWiki? markup language.

Home Page: http://code.google.com/p/wikicloth/

License: MIT License

Ruby 100.00%

wikicloth's Introduction

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 gem
  sudo gem install pkg/wikicloth-0.2.0.gem

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

    include_resource do |resource,options|
      case resource
      when "date"
        Time.now.to_s
      else
        params[resource] unless params[resource].nil?
      end
    end

  end

  @wiki = WikiParser.new({ 
    :params => { "PAGENAME" => "Testing123" }, 
    :data => "[[ Hello World ]] From {{ PAGENAME }} on {{ date }}\n" 
  })

  @wiki.to_html =>
  <p>
  <a href="javascript:alert('You clicked on: Hello World');">Hello World</a> From Testing123 on Wed Jul 08 22:23:44 -0400 2009
  </p>

wikicloth's People

Contributors

emily avatar chocolateboy avatar

Stargazers

Sebastian Cohnen avatar

Watchers

Sebastian Cohnen avatar James Cloos avatar  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.