GitHub README.md模板

GitHub Markup

We use this library on GitHub when rendering your README or any other rich text file.

Markups

The following markups are supported. The dependencies listed are required if you wish to run the library.

Contributing

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, /re?st(.txt)?/)

Here we're telling GitHub Markup of the existence of a rest2html command which should be used for any file ending in rest, rst, rest.txt or rst.txt. 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 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

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

  1. Fork it.
  2. Create a branch (git checkout -b my_markup)
  3. Commit your changes (git commit -am "Added Snarkdown")
  4. Push to the branch (git push origin my_markup)
  5. Open a Pull Request
  6. Enjoy a refreshing Diet Coke and wait

转载于:https://my.oschina.net/u/153733/blog/91903

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值