| CARVIEW |
defunkt / github-markup
- Source
- Commits
- Network (4)
- Issues (0)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
The code we use to render README.your_favorite_markup — Read more
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Fri Oct 30 23:13:44 -0700 2009 | always pyc [defunkt] |
| |
.kick | Fri Oct 30 18:14:35 -0700 2009 | add .kick, i love it [defunkt] |
| |
HISTORY.md | Tue Feb 09 13:13:50 -0800 2010 | 0.2.2 [defunkt] |
| |
LICENSE | Fri Oct 30 18:17:47 -0700 2009 | license [defunkt] |
| |
README.md | Tue Feb 09 12:44:20 -0800 2010 | how to run the tests? [defunkt] |
| |
Rakefile | Sun Jan 10 13:00:13 -0800 2010 | superfluous require [defunkt] |
| |
lib/ | Tue Feb 09 13:13:50 -0800 2010 | 0.2.2 [defunkt] |
| |
test/ | Tue Feb 09 12:47:33 -0800 2010 | fix pod test [defunkt] |
GitHub Markup
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.
Commands
If your markup is in a language other than Ruby, drop a translator
script in 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
guidance:
command(:rest2html, /rest|rst/)
Here we're telling GitHub Markup of the existence of a rest2html
command which should be used for any file ending in rest or
rst. Any regular expression will do.
Finally add your tests. Create a README.extension in test/markups
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: rake
If nothing complains, congratulations!
Classes
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
file to 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
Commands section.
Installation
gem install github-markup
gem install org-ruby
Usage
require 'github/markup'
GitHub::Markup.render('README.markdown', "* One\n* Two")
Or, more realistically:
require 'github/markup'
GitHub::Markup.render(file, File.read(file))
Testing
To run the tests:
$ rake
To add tests see the Commands section earlier in this
README.
Contributing
- 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
