all repos — markup @ 70f136e29efa1f7ebd73fbae1b3396bcf377fb00

The code we use to render README.your_favorite_markup

add rdoc markup
Chris Wanstrath chris@ozmm.org
Fri, 30 Oct 2009 23:07:01 -0700
commit

70f136e29efa1f7ebd73fbae1b3396bcf377fb00

parent

58b57b5fc86e8c1f98aa47d62397ba542ce9e4d9

3 files changed, 33 insertions(+), 0 deletions(-)

jump to
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.rblib/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.rbtest/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