Determines which markup library to use to render a content file (e.g. README) on GitHub
Перейти к файлу
Brandon Keepers ef25634ef9 Render with HTML pipeline 2014-12-22 12:51:21 -05:00
bin $ github-markup FILE.md 2010-03-11 14:17:55 -08:00
lib Merge pull request #370 from moskvax/rest2html-code-not-tt 2014-11-20 20:47:53 -08:00
script Update docs and bootstrap for asciidoc 2014-01-21 21:17:14 -08:00
test Render with HTML pipeline 2014-12-22 12:51:21 -05:00
.gitignore bin is not ignored 2014-04-23 10:10:17 -04:00
.kick add .kick, i love it 2009-10-30 18:14:35 -07:00
.travis.yml Reparations to the travis.yml file 2014-11-20 21:19:51 -08:00
CONTRIBUTING.md Fix docs for testing in GitHub 2014-04-23 10:12:24 -04:00
Gemfile Merge pull request #326 from wallyqs/org-ruby-update-0.9.7 2014-10-02 12:38:33 -04:00
HISTORY.md Release 1.3.1 2014-11-13 09:42:00 -05:00
LICENSE license 2009-10-30 18:17:47 -07:00
README.md Update README.md 2014-08-21 15:12:49 -07:00
Rakefile use bundler's rake tasks for releasing 2014-04-23 09:20:08 -04:00
github-markup.gemspec Render with HTML pipeline 2014-12-22 12:51:21 -05:00

README.md

GitHub Markup

We use this library on GitHub when rendering your README or any other rich text file. The generated HTML is then run through filters in the html-pipeline to perform things like sanitization and syntax highlighting.

Markups

The following markups are supported. The dependencies listed are required if you wish to run the library. You can also run script/bootstrap to fetch them all.

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))

Contributing

See Contributing

HTML sanitization

HTML rendered by the various markup language processors gets passed through an HTML sanitization filter for security reasons. HTML elements not in the whitelist are removed. HTML attributes not in the whitelist are removed from the preserved elements.

The following HTML elements, organized by category, are whitelisted:

Type Elements
Headings h1, h2, h3, h4, h5, h6, h7, h8
Prose p, div, blockquote
Formatted pre
Inline b, i, strong, em, tt, code, ins, del, sup, sub, kbd, samp, q, var
Lists ol, ul, li, dl, dt, dd
Tables table, thead, tbody, tfoot, tr, td, th
Breaks br, hr
Ruby (East Asian) ruby, rt, rp

The following attributes, organized by element, are whitelisted:

Element Attributes
a href (http://, https://, mailto://, github-windows://, and github-mac:// URI schemes and relative paths only)
img src (http:// and https:// URI schemes and relative paths only)
div itemscope, itemtype
All abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, charset, checked, cite, clear, cols, colspan, color, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, hreflang, hspace, ismap, label, lang, longdesc, maxlength, media, method, multiple, name, nohref, noshade, nowrap, prompt, readonly, rel, rev, rows, rowspan, rules, scope, selected, shape, size, span, start, summary, tabindex, target, title, type, usemap, valign, value, vspace, width, itemprop

Note that the id attribute is not whitelisted.