all repos — markup @ v0.2.0

The code we use to render README.your_favorite_markup

README.md (view raw)

 1GitHub Markup
 2=============
 3
 4We use this library on GitHub when rendering your README or any other
 5rich text file.
 6
 7Want to contribute? Great! There are two ways to add markups.
 8
 9
10### Commands
11
12If your markup is in a language other than Ruby, drop a translator
13script in `lib/github/commands` which accepts input on STDIN and
14returns HTML on STDOUT. See [rest2html][r2h] for an example.
15
16Once your script is in place, edit `lib/github/markups.rb` and tell
17GitHub Markup about it. Again we look to [rest2html][r2hc] for
18guidance:
19
20    command(:rest2html, /rest|rst/)
21
22Here we're telling GitHub Markup of the existence of a `rest2html`
23command which should be used for any file ending in `rest` or
24`rst`. Any regular expression will do.
25
26Finally add your tests. Create a `README.extension` in `test/markups`
27along with a `README.extension.html`. As you may imagine, the
28`README.extension` should be your known input and the
29`README.extension.html` should be the desired output.
30
31Now run the tests: `rake`
32
33If nothing complains, congratulations!
34
35
36### Classes
37
38If your markup can be translated using a Ruby library, that's
39great. Check out Check `lib/github/markups.rb` for some
40examples. Let's look at Markdown:
41
42    markup(:markdown, /md|mkdn?|markdown/) do |content|
43      Markdown.new(content).to_html
44    end
45
46We give the `markup` method three bits of information: the name of the
47file to `require`, a regular expression for extensions to match, and a
48block to run with unformatted markup which should return HTML.
49
50If you need to monkeypatch a RubyGem or something, check out the
51included RDoc example.
52
53Tests should be added in the same manner as described under the
54`Commands` section.
55
56
57Installation
58-----------
59
60    gem install github-markup
61    gem install org-ruby
62
63
64Usage
65-----
66
67    require 'github/markup'
68    GitHub::Markup.render('README.markdown', "* One\n* Two")
69
70Or, more realistically:
71
72    require 'github/markup'
73    GitHub::Markup.render(file, File.read(file))
74
75
76Contributing
77------------
78
791. Fork it.
802. Create a branch
813. Commit your changes
824. Push to the branch
835. Create an [Issue][1] with a link to your branch
846. Enjoy a refreshing Diet Coke and wait
85
86
87[r2h]: http://github.com/defunkt/github-markup/tree/master/lib/github/commands/rest2html
88[r2hc]: http://github.com/defunkt/github-markup/tree/master/lib/github/markups.rb#L13
89[1]: http://github.com/defunkt/github-markup/issues