github-markup 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +1 -1
- data/HISTORY.md +9 -0
- data/README.md +3 -3
- data/lib/github-markup.rb +1 -1
- data/lib/github/markup.rb +28 -28
- data/lib/github/markup/command_implementation.rb +1 -1
- data/lib/github/markup/gem_implementation.rb +3 -3
- data/lib/github/markup/implementation.rb +1 -1
- data/lib/github/markup/markdown.rb +12 -11
- data/lib/github/markup/rdoc.rb +1 -1
- data/lib/github/markups.rb +5 -5
- data/test/markup_test.rb +7 -4
- metadata +3 -6
- data/test/markups/README.rmd +0 -3
- data/test/markups/README.rmd.html +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0ec4d2984d74d5ed1cfdcfdf4d01040929051c8c020bc2c148c370c749a281e
|
4
|
+
data.tar.gz: f2e8584d059cc3926d07d1da27c0e937ab00d2a889d444cb474d02260f481ea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0803abf3417dcc2175ab89cd305c769f9b3ace4d2b71612fb42f69ac9719cd01603a37706f22ea90b3761bbab9a8cb72b7cd9ef94fef2527cd31d925fa4bfcad'
|
7
|
+
data.tar.gz: e8ea52227010f3131542924a13e23f4295e46aa0d09c6c30d015d9434b8390041df6e4ceb15629b4e48fdd47ddaa2d3d9353a3d1b97459e36dae953ffeeedea2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [opensource@github.com](mailto:opensource@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: https://contributor-covenant.org
|
46
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
|
4
4
|
|
5
|
-
This project adheres to
|
5
|
+
This project adheres to a [Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
|
6
6
|
|
7
|
-
[code-of-conduct]:
|
7
|
+
[code-of-conduct]: CODE_OF_CONDUCT.md
|
8
8
|
|
9
9
|
This library's only job is to decide which markup format to use and call out to an external library to convert the markup to HTML (see the [README](README.md) for more information on how markup is rendered on GitHub.com).
|
10
10
|
|
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ gem "posix-spawn", :platforms => :ruby
|
|
5
5
|
gem "redcarpet", :platforms => :ruby
|
6
6
|
gem "kramdown", :platforms => :jruby
|
7
7
|
gem "RedCloth"
|
8
|
-
gem "commonmarker", "~> 0.
|
8
|
+
gem "commonmarker", "~> 0.18.1"
|
9
9
|
gem "rdoc", "~>3.6"
|
10
10
|
gem "org-ruby", "= 0.9.9"
|
11
11
|
gem "creole", "~>0.3.6"
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 3.0.0 - 2018-10-18
|
2
|
+
|
3
|
+
* Allow passing options through to CommonMarker [#1236](https://github.com/github/markup/pull/1236)
|
4
|
+
* Symlink option is now a keyword arg [#1236](https://github.com/github/markup/pull/1236)
|
5
|
+
|
6
|
+
## 2.0.2 - 2018-10-15
|
7
|
+
|
8
|
+
* Don't render rmd files as Markdown [#1235](https://github.com/github/markup/pull/1235)
|
9
|
+
|
1
10
|
## 2.0.1 - 2018-06-29
|
2
11
|
|
3
12
|
* Create anchor for every =item directive in POD files [#1165](https://github.com/github/markup/pull/1165)
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
GitHub Markup
|
2
2
|
=============
|
3
3
|
|
4
|
-
This library is the first step of a journey that every markup file in a repository goes on before it is rendered on GitHub.com:
|
4
|
+
This library is the **first step** of a journey that every markup file in a repository goes on before it is rendered on GitHub.com:
|
5
5
|
|
6
|
-
1.
|
7
|
-
1. The HTML is sanitized, aggressively removing things that could harm you and your kin—such as `script` tags, inline-styles, and `class` or `id` attributes.
|
6
|
+
1. `github-markup` selects an _underlying library_ to convert the raw markup to HTML. See the list of [supported markup formats](#markups) below.
|
7
|
+
1. The HTML is sanitized, aggressively removing things that could harm you and your kin—such as `script` tags, inline-styles, and `class` or `id` attributes.
|
8
8
|
1. Syntax highlighting is performed on code blocks. See [github/linguist](https://github.com/github/linguist#syntax-highlighting) for more information about syntax highlighting.
|
9
9
|
1. The HTML is passed through other filters in the [html-pipeline](https://github.com/jch/html-pipeline) that add special sauce, such as [emoji](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/emoji_filter.rb), [task lists](https://github.com/github/task_list/blob/master/lib/task_list/filter.rb), [named anchors](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb), [CDN caching for images](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/camo_filter.rb), and [autolinking](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/autolink_filter.rb).
|
10
10
|
1. The resulting HTML is rendered on GitHub.com.
|
data/lib/github-markup.rb
CHANGED
data/lib/github/markup.rb
CHANGED
@@ -20,38 +20,36 @@ module GitHub
|
|
20
20
|
MARKUP_RST = :rst
|
21
21
|
MARKUP_TEXTILE = :textile
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
module Markup
|
25
25
|
extend self
|
26
|
-
|
26
|
+
|
27
27
|
@@markups = {}
|
28
28
|
|
29
29
|
def markups
|
30
30
|
@@markups
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def markup_impls
|
34
34
|
markups.values
|
35
35
|
end
|
36
36
|
|
37
37
|
def preload!
|
38
|
-
markup_impls.each
|
39
|
-
markup.load
|
40
|
-
end
|
38
|
+
markup_impls.each(&:load)
|
41
39
|
end
|
42
40
|
|
43
|
-
def render(filename, content, symlink
|
44
|
-
if impl = renderer(filename, content, symlink)
|
45
|
-
impl.render(filename, content)
|
41
|
+
def render(filename, content, symlink: false, options: {})
|
42
|
+
if (impl = renderer(filename, content, symlink: symlink))
|
43
|
+
impl.render(filename, content, options: options)
|
46
44
|
else
|
47
45
|
content
|
48
46
|
end
|
49
47
|
end
|
50
|
-
|
48
|
+
|
51
49
|
def render_s(symbol, content)
|
52
|
-
if content.nil?
|
53
|
-
|
54
|
-
|
50
|
+
raise ArgumentError, 'Can not render a nil.' if content.nil?
|
51
|
+
|
52
|
+
if markups.key?(symbol)
|
55
53
|
markups[symbol].render(nil, content)
|
56
54
|
else
|
57
55
|
content
|
@@ -59,11 +57,12 @@ module GitHub
|
|
59
57
|
end
|
60
58
|
|
61
59
|
def markup(symbol, gem_name, regexp, languages, opts = {}, &block)
|
62
|
-
|
60
|
+
impl = GemImplementation.new(regexp, languages, gem_name, &block)
|
61
|
+
markup_impl(symbol, impl)
|
63
62
|
end
|
64
|
-
|
63
|
+
|
65
64
|
def markup_impl(symbol, impl)
|
66
|
-
if markups.
|
65
|
+
if markups.key?(symbol)
|
67
66
|
raise ArgumentError, "The '#{symbol}' symbol is already defined."
|
68
67
|
end
|
69
68
|
markups[symbol] = impl
|
@@ -74,25 +73,26 @@ module GitHub
|
|
74
73
|
command = file
|
75
74
|
end
|
76
75
|
|
77
|
-
|
76
|
+
impl = CommandImplementation.new(regexp, languages, command, name, &block)
|
77
|
+
markup_impl(symbol, impl)
|
78
78
|
end
|
79
79
|
|
80
|
-
def can_render?(filename, content, symlink
|
81
|
-
|
80
|
+
def can_render?(filename, content, symlink: false)
|
81
|
+
renderer(filename, content, symlink: symlink) != nil
|
82
82
|
end
|
83
83
|
|
84
|
-
def renderer(filename, content, symlink
|
85
|
-
language = language(filename, content, symlink)
|
86
|
-
markup_impls.find
|
84
|
+
def renderer(filename, content, symlink: false)
|
85
|
+
language = language(filename, content, symlink: symlink)
|
86
|
+
markup_impls.find do |impl|
|
87
87
|
impl.match?(filename, language)
|
88
|
-
|
88
|
+
end
|
89
89
|
end
|
90
90
|
|
91
|
-
def language(filename, content, symlink
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
def language(filename, content, symlink: false)
|
92
|
+
return unless defined?(::Linguist)
|
93
|
+
|
94
|
+
blob = Linguist::Blob.new(filename, content, symlink: symlink)
|
95
|
+
Linguist.detect(blob, allow_empty: true)
|
96
96
|
end
|
97
97
|
|
98
98
|
# Define markups
|
@@ -12,14 +12,14 @@ module GitHub
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def load
|
15
|
-
return if @loaded
|
15
|
+
return if defined?(@loaded) && @loaded
|
16
16
|
require gem_name
|
17
17
|
@loaded = true
|
18
18
|
end
|
19
19
|
|
20
|
-
def render(filename, content)
|
20
|
+
def render(filename, content, options: {})
|
21
21
|
load
|
22
|
-
renderer.call(filename, content)
|
22
|
+
renderer.call(filename, content, options: options)
|
23
23
|
end
|
24
24
|
|
25
25
|
def name
|
@@ -4,32 +4,33 @@ module GitHub
|
|
4
4
|
module Markup
|
5
5
|
class Markdown < Implementation
|
6
6
|
MARKDOWN_GEMS = {
|
7
|
-
"commonmarker" => proc { |content|
|
8
|
-
|
7
|
+
"commonmarker" => proc { |content, options: {}|
|
8
|
+
commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
|
9
|
+
CommonMarker.render_html(content, commonmarker_opts, [:tagfilter, :autolink, :table, :strikethrough])
|
9
10
|
},
|
10
|
-
"github/markdown" => proc { |content|
|
11
|
+
"github/markdown" => proc { |content, options: {}|
|
11
12
|
GitHub::Markdown.render(content)
|
12
13
|
},
|
13
|
-
"redcarpet" => proc { |content|
|
14
|
+
"redcarpet" => proc { |content, options: {}|
|
14
15
|
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content)
|
15
16
|
},
|
16
|
-
"rdiscount" => proc { |content|
|
17
|
+
"rdiscount" => proc { |content, options: {}|
|
17
18
|
RDiscount.new(content).to_html
|
18
19
|
},
|
19
|
-
"maruku" => proc { |content|
|
20
|
+
"maruku" => proc { |content, options: {}|
|
20
21
|
Maruku.new(content).to_html
|
21
22
|
},
|
22
|
-
"kramdown" => proc { |content|
|
23
|
+
"kramdown" => proc { |content, options: {}|
|
23
24
|
Kramdown::Document.new(content).to_html
|
24
25
|
},
|
25
|
-
"bluecloth" => proc { |content|
|
26
|
+
"bluecloth" => proc { |content, options: {}|
|
26
27
|
BlueCloth.new(content).to_html
|
27
28
|
},
|
28
29
|
}
|
29
30
|
|
30
31
|
def initialize
|
31
32
|
super(
|
32
|
-
/md|
|
33
|
+
/md|mkdn?|mdwn|mdown|markdown|litcoffee/i,
|
33
34
|
["Markdown", "RMarkdown", "Literate CoffeeScript"])
|
34
35
|
end
|
35
36
|
|
@@ -44,9 +45,9 @@ module GitHub
|
|
44
45
|
raise LoadError, "no suitable markdown gem found"
|
45
46
|
end
|
46
47
|
|
47
|
-
def render(filename, content)
|
48
|
+
def render(filename, content, options: {})
|
48
49
|
load
|
49
|
-
@renderer.call(content)
|
50
|
+
@renderer.call(content, options: options)
|
50
51
|
end
|
51
52
|
|
52
53
|
def name
|
data/lib/github/markup/rdoc.rb
CHANGED
data/lib/github/markups.rb
CHANGED
@@ -4,30 +4,30 @@ require "shellwords"
|
|
4
4
|
|
5
5
|
markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)
|
6
6
|
|
7
|
-
markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content|
|
7
|
+
markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
|
8
8
|
RedCloth.new(content).to_html
|
9
9
|
end
|
10
10
|
|
11
11
|
markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new)
|
12
12
|
|
13
|
-
markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content|
|
13
|
+
markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content, options: {}|
|
14
14
|
Orgmode::Parser.new(content, {
|
15
15
|
:allow_include_files => false,
|
16
16
|
:skip_syntax_highlight => true
|
17
17
|
}).to_html
|
18
18
|
end
|
19
19
|
|
20
|
-
markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content|
|
20
|
+
markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content, options: {}|
|
21
21
|
Creole.creolize(content)
|
22
22
|
end
|
23
23
|
|
24
|
-
markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content|
|
24
|
+
markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content, options: {}|
|
25
25
|
wikicloth = WikiCloth::WikiCloth.new(:data => content)
|
26
26
|
WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS << 'tt' unless WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS.include?('tt')
|
27
27
|
wikicloth.to_html(:noedit => true)
|
28
28
|
end
|
29
29
|
|
30
|
-
markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content|
|
30
|
+
markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content, options: {}|
|
31
31
|
attributes = {
|
32
32
|
'showtitle' => '@',
|
33
33
|
'idprefix' => '',
|
data/test/markup_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
|
4
4
|
|
@@ -78,8 +78,6 @@ message
|
|
78
78
|
def test_knows_what_it_can_and_cannot_render
|
79
79
|
assert_equal false, GitHub::Markup.can_render?('README.html', '<h1>Title</h1>')
|
80
80
|
assert_equal true, GitHub::Markup.can_render?('README.markdown', '=== Title')
|
81
|
-
assert_equal true, GitHub::Markup.can_render?('README.rmd', '=== Title')
|
82
|
-
assert_equal true, GitHub::Markup.can_render?('README.Rmd', '=== Title')
|
83
81
|
assert_equal false, GitHub::Markup.can_render?('README.cmd', 'echo 1')
|
84
82
|
assert_equal true, GitHub::Markup.can_render?('README.litcoffee', 'Title')
|
85
83
|
end
|
@@ -104,7 +102,7 @@ message
|
|
104
102
|
GitHub::Markup.command(:doesntmatter, 'test/fixtures/fail.sh', /fail/, ['Java'], 'fail')
|
105
103
|
assert GitHub::Markup.can_render?('README.java', 'stop swallowing errors')
|
106
104
|
begin
|
107
|
-
GitHub::Markup.render('README.java', "stop swallowing errors", false)
|
105
|
+
GitHub::Markup.render('README.java', "stop swallowing errors", symlink: false)
|
108
106
|
rescue GitHub::Markup::CommandError => e
|
109
107
|
assert_equal "failure message", e.message
|
110
108
|
else
|
@@ -116,4 +114,9 @@ message
|
|
116
114
|
content = "Noël"
|
117
115
|
assert_equal content.encoding.name, GitHub::Markup.render('Foo.rst', content).encoding.name
|
118
116
|
end
|
117
|
+
|
118
|
+
def test_commonmarker_options
|
119
|
+
assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world")
|
120
|
+
assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})
|
121
|
+
end
|
119
122
|
end
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- ".gitignore"
|
146
146
|
- ".kick"
|
147
147
|
- ".travis.yml"
|
148
|
+
- CODE_OF_CONDUCT.md
|
148
149
|
- CONTRIBUTING.md
|
149
150
|
- Gemfile
|
150
151
|
- HISTORY.md
|
@@ -188,8 +189,6 @@ files:
|
|
188
189
|
- test/markups/README.pod.html
|
189
190
|
- test/markups/README.rdoc
|
190
191
|
- test/markups/README.rdoc.html
|
191
|
-
- test/markups/README.rmd
|
192
|
-
- test/markups/README.rmd.html
|
193
192
|
- test/markups/README.rst
|
194
193
|
- test/markups/README.rst.html
|
195
194
|
- test/markups/README.rst.txt
|
@@ -247,8 +246,6 @@ test_files:
|
|
247
246
|
- test/markups/README.pod.html
|
248
247
|
- test/markups/README.rdoc
|
249
248
|
- test/markups/README.rdoc.html
|
250
|
-
- test/markups/README.rmd
|
251
|
-
- test/markups/README.rmd.html
|
252
249
|
- test/markups/README.rst
|
253
250
|
- test/markups/README.rst.html
|
254
251
|
- test/markups/README.rst.txt
|
data/test/markups/README.rmd
DELETED