all repos — markup @ 58b57b5fc86e8c1f98aa47d62397ba542ce9e4d9

The code we use to render README.your_favorite_markup

add rest
Chris Wanstrath chris@ozmm.org
Fri, 30 Oct 2009 22:59:26 -0700
commit

58b57b5fc86e8c1f98aa47d62397ba542ce9e4d9

parent

215b7790e83d29821afc43aff8534c840ad9a4f5

3 files changed, 55 insertions(+), 8 deletions(-)

jump to
A lib/github/commands/rest2html

@@ -0,0 +1,48 @@

+#!/usr/bin/env python + +"""A small wrapper file for parsing ReST files at GitHub.""" + +__author__ = "Jannis Leidel" +__copyright__ = "Copyright (C) 2008 Jannis Leidel" +__license__ = "Public Domain" +__version__ = "0.1" + +try: + import locale + locale.setlocale(locale.LC_ALL, '') +except: + pass + +import sys +from docutils.core import publish_parts +from docutils.writers.html4css1 import Writer + +SETTINGS = { + 'cloak_email_addresses': True, + 'file_insertion_enabled': False, + 'raw_enabled': False, + 'strip_comments': True, +} + +def main(): + """ + Parses the given ReST file or the redirected string input and returns the + HTML body. + + Usage: rest2html < README.rst + rest2html README.rst + """ + try: + text = open(sys.argv[1], 'r').read() + except IOError: # given filename could not be found + return '' + except IndexError: # no filename given + text = sys.stdin.read() + + parts = publish_parts(text, writer=Writer(), settings_overrides=SETTINGS) + if 'html_body' in parts: + return parts['html_body'] + return '' + +if __name__ == '__main__': + print main()
M lib/github/markups.rblib/github/markups.rb

@@ -6,7 +6,4 @@ markup(:redcloth, /textile/) do |content|

RedCloth.new(content).to_html end -markup('github/markup/rest', /rest|rst/) do |content| - GitHub::Markup::ReST.translate(content) -end - +command(:rest2html, /rest|rst/)
M test/markup_test.rbtest/markup_test.rb

@@ -47,9 +47,11 @@ 1. Blah blah ``code`` blah

2. More ``code``, hooray input -<ul> -\t<li>One</li> -\t<li>Two</li> -</ul> +<div class="document"> +<ol class="arabic simple"> +<li>Blah blah <tt class="docutils literal">code</tt> blah</li> +<li>More <tt class="docutils literal">code</tt>, hooray</li> +</ol> +</div>\n output end