File: README

package info (click to toggle)
ruby-wikicloth 0.8.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 624 kB
  • ctags: 294
  • sloc: ruby: 2,545; makefile: 16; sh: 11
file content (72 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Ruby implementation of the MediaWiki markup language.

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

    * Variables, Templates {{ ... }}
    * Links
          o External Links [ ... ]
          o Internal Links, Images [[ ... ]]
    * 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>