github-markup 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/github-markup.gemspec +1 -1
- data/lib/github-markup.rb +1 -1
- data/lib/github/commands/rest2html +16 -0
- data/test/markups/README.rst.html +0 -6
- data/test/markups/README.rst.txt.html +0 -7
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35584dcddd6c4d30a24ef157cb42369161b24af
|
4
|
+
data.tar.gz: 2b71a47126ef2dcbfdcf2779c4b892eabc22db53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb7a19c1bc478049846d7a7ca53f2d0c3a021f5e99a861de190ff5398e0fe66017bd721818ba70848d039eab2b09bef97dd3d61f9c1048f5fab662c02b6130d
|
7
|
+
data.tar.gz: 5904bb20ed5edf8a027f79468e42719c7220a37846f9fe8d22697535ec272c14c91f4f6474dd45441ad81cdc538d55f074a2b5b05ae5e470a17ac7c7fec2ea05
|
data/README.md
CHANGED
@@ -21,6 +21,30 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
|
|
21
21
|
* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML`
|
22
22
|
comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
|
23
23
|
|
24
|
+
HTML sanitization
|
25
|
+
-----------------
|
26
|
+
|
27
|
+
HTML rendered by the various markup language processors gets passed through an [HTML sanitization filter](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/sanitization_filter.rb) for security reasons. HTML elements not in the whitelist are removed. HTML attributes not in the whitelist are removed from the preserved elements.
|
28
|
+
|
29
|
+
The following HTML elements, organized by category, are whitelisted:
|
30
|
+
|
31
|
+
* Headings: h1, h2, h3, h4, h5, h6, h7, h8
|
32
|
+
* Prose: p, div, blockquote
|
33
|
+
* Preformatted: pre
|
34
|
+
* Inline: b, i, strong, em, tt, code, ins, del, sup, sub, kbd, samp, q, var
|
35
|
+
* Lists: ol, ul, li, dl, dt, dd
|
36
|
+
* Tables: table, thead, tbody, tfoot, tr, td, th
|
37
|
+
* Breaks: br, hr
|
38
|
+
* Ruby (East Asian): ruby, rt, rp
|
39
|
+
|
40
|
+
The following attributes, organized by element, are whitelisted:
|
41
|
+
|
42
|
+
* a: href (http://, https://, mailto://, github-windows:// and github-mac:// URI schemes and relative paths only)
|
43
|
+
* img: src (http:// and https::// URI schemes and relative paths only)
|
44
|
+
* div: itemscope, itemtype
|
45
|
+
* 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
|
46
|
+
|
47
|
+
Note that the id attribute is *not* whitelisted.
|
24
48
|
|
25
49
|
Contributing
|
26
50
|
------------
|
data/github-markup.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
## the sub! line in the Rakefile
|
17
17
|
s.name = 'github-markup'
|
18
18
|
s.version = GitHub::Markup::VERSION
|
19
|
-
s.date = '2014-
|
19
|
+
s.date = '2014-02-14'
|
20
20
|
s.executables = ['github-markup']
|
21
21
|
|
22
22
|
## Make sure your summary is short. The description may be as long
|
data/lib/github-markup.rb
CHANGED
@@ -8,6 +8,7 @@ Brandon Keepers <bkeepers@github.com>
|
|
8
8
|
Bryan Veloso <bryan@revyver.com>
|
9
9
|
Chris Wanstrath <chris@ozmm.org>
|
10
10
|
Dave Abrahams <dave@boostpro.com>
|
11
|
+
Garen Torikian <garen@github.com>
|
11
12
|
Gasper Zejn <zejn@kiberpipa.org>
|
12
13
|
Michael Jones <m.pricejones@gmail.com>
|
13
14
|
Sam Whited <sam@samwhited.com>
|
@@ -50,6 +51,21 @@ SETTINGS = {
|
|
50
51
|
}
|
51
52
|
|
52
53
|
class GitHubHTMLTranslator(HTMLTranslator):
|
54
|
+
# removes the <div class="document"> tag wrapped around docs
|
55
|
+
# see also: http://bit.ly/1exfq2h (warning! sourceforge link.)
|
56
|
+
def depart_document(self, node):
|
57
|
+
HTMLTranslator.depart_document(self, node)
|
58
|
+
self.html_body.pop(0)
|
59
|
+
self.html_body.pop()
|
60
|
+
|
61
|
+
# technique for visiting sections, without generating additional divs
|
62
|
+
# see also: http://bit.ly/NHtyRx
|
63
|
+
def visit_section(self, node):
|
64
|
+
self.section_level += 1
|
65
|
+
|
66
|
+
def depart_section(self, node):
|
67
|
+
self.section_level -= 1
|
68
|
+
|
53
69
|
def visit_literal_block(self, node):
|
54
70
|
classes = node.attributes['classes']
|
55
71
|
if len(classes) >= 2 and classes[0] == 'code':
|
@@ -1,8 +1,5 @@
|
|
1
|
-
<div class="document">
|
2
|
-
<div class="section" id="header-1">
|
3
1
|
<h1>Header 1</h1>
|
4
2
|
<p>Example text.</p>
|
5
|
-
<div class="section" id="header-2">
|
6
3
|
<h2>Header 2</h2>
|
7
4
|
<ol class="arabic simple">
|
8
5
|
<li>Blah blah <tt class="docutils literal">code</tt> blah</li>
|
@@ -32,6 +29,3 @@
|
|
32
29
|
</tr>
|
33
30
|
</tbody>
|
34
31
|
</table>
|
35
|
-
</div>
|
36
|
-
</div>
|
37
|
-
</div>
|
@@ -1,14 +1,7 @@
|
|
1
|
-
<div class="document">
|
2
|
-
<div class="section" id="header-1">
|
3
1
|
<h1>Header 1</h1>
|
4
2
|
<p>Example text.</p>
|
5
|
-
<div class="section" id="header-2">
|
6
3
|
<h2>Header 2</h2>
|
7
4
|
<ol class="arabic simple">
|
8
5
|
<li>Blah blah <tt class="docutils literal">code</tt> blah</li>
|
9
6
|
<li>More <tt class="docutils literal">code</tt>, hooray</li>
|
10
7
|
</ol>
|
11
|
-
</div>
|
12
|
-
</div>
|
13
|
-
</div>
|
14
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
This gem is used by GitHub to render any fancy markup such as
|
@@ -73,22 +73,22 @@ licenses: []
|
|
73
73
|
metadata: {}
|
74
74
|
post_install_message:
|
75
75
|
rdoc_options:
|
76
|
-
- --charset=UTF-8
|
76
|
+
- "--charset=UTF-8"
|
77
77
|
require_paths:
|
78
78
|
- lib
|
79
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.0
|
91
|
+
rubygems_version: 2.2.0
|
92
92
|
signing_key:
|
93
93
|
specification_version: 2
|
94
94
|
summary: The code GitHub uses to render README.markup
|