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
|
h1. WikiCloth "!https://api.travis-ci.org/nricciar/wikicloth.png!":https://travis-ci.org/nricciar/wikicloth
Ruby implementation of the MediaWiki markup language.
h2. Supports
* Variables, Templates {{ ... }}
* Links
** External Links [ ... ]
** Internal Links, Images [[ ... ]]
* Markup
** == Headings ==
** Lists (*#;:)
** bold (<code>'''</code>), italic (<code>''</code>) or both (<code>'''''</code>)
** Horizontal rule (----)
** "Tables":https://github.com/nricciar/wikicloth/wiki/Tables
** Table of Contents [<code>__NOTOC__, __FORCETOC__, __TOC__</code>]
* <code><code>,<nowiki>,<pre></code> (disable wiki markup)
* <code><ref></code> and <code><references/></code> support
* "html sanitization":https://github.com/nricciar/wikicloth/wiki/Html-Sanitization
For more information about the MediaWiki markup see "https://www.mediawiki.org/wiki/Markup_spec":https://www.mediawiki.org/wiki/Markup_spec
h2. Install
<pre> git clone git://github.com/nricciar/wikicloth.git
cd wikicloth/
rake install</pre>
h2. Usage
<pre> @wiki = WikiCloth::Parser.new({
:data => "<nowiki>{{test}}</nowiki> ''Hello {{test}}!''\n",
:params => { "test" => "World" } })
@wiki.to_html => "<p>{{test}} <i>Hello World!</i></p>"</pre>
h2. Advanced Usage
Most features of WikiCloth can be overriden as needed...
<pre> 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></pre>
|