add rdoc markup
Chris Wanstrath chris@ozmm.org
Fri, 30 Oct 2009 23:07:01 -0700
3 files changed,
33 insertions(+),
0 deletions(-)
A
lib/github/markup/rdoc.rb
@@ -0,0 +1,19 @@
+require 'rdoc/generators/html_generator' + +module GitHub + module Markup + class RDoc + def initialize(content) + @content = content + end + + def to_html + simple_markup = SM::SimpleMarkup.new + generator = Generators::HyperlinkHtml.new(nil, OpenStruct.new) + simple_markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK) + simple_markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK) + simple_markup.convert(@content, generator) + end + end + end +end
M
lib/github/markups.rb
→
lib/github/markups.rb
@@ -6,4 +6,8 @@ markup(:redcloth, /textile/) do |content|
RedCloth.new(content).to_html end +markup('github/markup/rdoc', /rdoc/) do |content| + GitHub::Markup::RDoc.new(content).to_html +end + command(:rest2html, /rest|rst/)
M
test/markup_test.rb
→
test/markup_test.rb
@@ -42,6 +42,16 @@ * One
* Two output + test 'README.rdoc', <<-input, <<-output +* One +* Two +input +<ul> +<li>One\n\n</li> +<li>Two\n\n</li> +</ul> +output + test 'README.rst', <<-input, <<-output 1. Blah blah ``code`` blah