
wikicloth
Ruby implementation of the MediaWiki markup language.
Source Code: http://github.com/nricciar/wikicloth
Supports
- Variables, Templates
{{ ... }}
- Links
- External Links
[ ... ]
- Internal Links, Images
[[ ... ]]
- (see also pipe trick)
- External Links
- Wikimedia Markup
== Headings ==
- Lists
(*#;:)
- bold
(''')
, italic('')
or both(''''')
- Horizontal rule
(----)
- Tables
<code>,<nowiki>,<pre>
(disable wiki markup)- space at the beginning of a line (
<pre>
)
- space at the beginning of a line (
<ref>
and<references/>
support- html sanitization
Getting Started
Install
./script/plugin install git://github.com/nricciar/wikicloth.git
Controller
``` include WikiCloth
def show @wiki = WikiCloth.new({ :data => "{{test}} ''Hello {{test}}!''\n", :params => { "test" => "World" } }) end ```
View
<%= @wiki.to_html -%>
Output
<p>{{test}} <i>Hello World!</i></p>
Wiki Links and Variable/Template Handling
Use the url_for
and link_attributes_for
methods to override the default URL for an [[internal link]]
. If you need even more control, the link_for
can also be used to return raw html.
``` class CustomLinkHandler < WikiCloth::WikiLinkHandler
def url_for(page) "javascript:alert('You clicked on: #{page}');" end
def link_attributes_for(page) { :href => url_for(page) } end
end ```
You can also override the include_resource
method to give you control over {{ template_variables }}
...
def include_resource(resource,options=[])
case resource
when "date"
Time.now.to_s
else
# default behavior
super(resource,options)
end
end
Controller
``` include WikiCloth
def show @wiki = WikiCloth.new({ :params => { "PAGENAME" => "Testing123" }, :link_handler => CustomLinkHandler.new, :data => "Hello World From {{ PAGENAME }} on {{ date }}\n" }) end ```
Output (@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>
Project Information
- License: MIT License
- 10 stars
- git-based source control