Ruby implementation of the MediaWiki markup language.
Ruby
160
126 commits
updated Sep 11, 2022
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>
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Ruby
92.4%
Lua
6.9%
Ruby implementation of the MediaWiki markup language.
Ruby
160
126 commits
updated Sep 11, 2022
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>
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Ruby
92.4%
Lua
6.9%