all repos — markup @ b12c42e3d8093b79f1091c99c6b96f58a736b8ce

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
  7Markups
  8-------
  9
 10The following markups are supported.  The dependencies listed are required if
 11you wish to run the library.
 12
 13* [.markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet` (https://github.com/tanoku/redcarpet)
 14* [.textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth`
 15* [.rdoc](http://rdoc.sourceforge.net/) -- `gem install rdoc -v 3.6.1`
 16* [.org](http://orgmode.org/) -- `gem install org-ruby`
 17* [.creole](http://wikicreole.org/) -- `gem install creole`
 18* [.mediawiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
 19* [.rst](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils`
 20* [.asciidoc](http://www.methods.co.nz/asciidoc/) -- `brew install asciidoc`
 21* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML`
 22  comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
 23
 24
 25Contributing
 26------------
 27
 28Want to contribute? Great! There are two ways to add markups.
 29
 30
 31### Commands
 32
 33If your markup is in a language other than Ruby, drop a translator
 34script in `lib/github/commands` which accepts input on STDIN and
 35returns HTML on STDOUT. See [rest2html][r2h] for an example.
 36
 37Once your script is in place, edit `lib/github/markups.rb` and tell
 38GitHub Markup about it. Again we look to [rest2html][r2hc] for
 39guidance:
 40
 41    command(:rest2html, /re?st(.txt)?/)
 42
 43Here we're telling GitHub Markup of the existence of a `rest2html`
 44command which should be used for any file ending in `rest`,
 45`rst`, `rest.txt` or `rst.txt`. Any regular expression will do.
 46
 47Finally add your tests. Create a `README.extension` in `test/markups`
 48along with a `README.extension.html`. As you may imagine, the
 49`README.extension` should be your known input and the
 50`README.extension.html` should be the desired output.
 51
 52Now run the tests: `rake`
 53
 54If nothing complains, congratulations!
 55
 56
 57### Classes
 58
 59If your markup can be translated using a Ruby library, that's
 60great. Check out Check `lib/github/markups.rb` for some
 61examples. Let's look at Markdown:
 62
 63    markup(:markdown, /md|mkdn?|markdown/) do |content|
 64      Markdown.new(content).to_html
 65    end
 66
 67We give the `markup` method three bits of information: the name of the
 68file to `require`, a regular expression for extensions to match, and a
 69block to run with unformatted markup which should return HTML.
 70
 71If you need to monkeypatch a RubyGem or something, check out the
 72included RDoc example.
 73
 74Tests should be added in the same manner as described under the
 75`Commands` section.
 76
 77
 78Installation
 79-----------
 80
 81    gem install github-markup
 82
 83
 84Usage
 85-----
 86
 87    require 'github/markup'
 88    GitHub::Markup.render('README.markdown', "* One\n* Two")
 89
 90Or, more realistically:
 91
 92    require 'github/markup'
 93    GitHub::Markup.render(file, File.read(file))
 94
 95
 96Testing
 97-------
 98
 99To run the tests:
100
101    $ rake
102
103To add tests see the `Commands` section earlier in this
104README.
105
106
107Contributing
108------------
109
1101. Fork it.
1112. Create a branch (`git checkout -b my_markup`)
1123. Commit your changes (`git commit -am "Added Snarkdown"`)
1134. Push to the branch (`git push origin my_markup`)
1145. Open a [Pull Request][1]
1156. Enjoy a refreshing Diet Coke and wait
116
117
118[r2h]: http://github.com/github/markup/tree/master/lib/github/commands/rest2html
119[r2hc]: http://github.com/github/markup/tree/master/lib/github/markups.rb#L13
120[1]: http://github.com/github/markup/pulls