We use this library on GitHub when rendering your README or any other rich text file.
Want to contribute? Great! There are two ways to add markups.
If your markup is in a language other than Ruby, drop a translator
lib/github/commands which accepts input on STDIN and
returns HTML on STDOUT. See rest2html for an example.
Once your script is in place, edit
lib/github/markups.rb and tell
GitHub Markup about it. Again we look to rest2html for
Here we're telling GitHub Markup of the existence of a
command which should be used for any file ending in
rst. Any regular expression will do.
Finally add your tests. Create a
along with a
README.extension.html. As you may imagine, the
README.extension should be your known input and the
README.extension.html should be the desired output.
Now run the tests:
If nothing complains, congratulations!
If your markup can be translated using a Ruby library, that's
great. Check out Check
lib/github/markups.rb for some
examples. Let's look at Markdown:
markup(:markdown, /md|mkdn?|markdown/) do |content| Markdown.new(content).to_html end
We give the
markup method three bits of information: the name of the
require, a regular expression for extensions to match, and a
block to run with unformatted markup which should return HTML.
If you need to monkeypatch a RubyGem or something, check out the included RDoc example.
Tests should be added in the same manner as described under the
gem install github-markup --source=http://gemcutter.org
require 'github/markup' GitHub::Markup.render('README.markdown', "* One\n* Two")
Or, more realistically:
require 'github/markup' GitHub::Markup.render(file, File.read(file))
- Fork it.
- Create a branch
- Commit your changes
- Push to the branch
- Create an Issue with a link to your branch
- Enjoy a refreshing Diet Coke and wait