Skip to content

Commit 4406f72

Browse files
committed
Merge remote-tracking branch 'origin/master' into JJ-master
2 parents e70b3ee + 11a355b commit 4406f72

17 files changed

+131
-71
lines changed

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 [[email protected]](mailto:[email protected]). 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/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
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).
44

5-
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
5+
This project adheres to a [Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code.
66

7-
[code-of-conduct]: http://todogroup.org/opencodeofconduct/#GitHub%20Markup/[email protected]
7+
[code-of-conduct]: CODE_OF_CONDUCT.md
88

99
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).
1010

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gem "posix-spawn", :platforms => :ruby
55
gem "redcarpet", :platforms => :ruby
66
gem "kramdown", :platforms => :jruby
77
gem "RedCloth"
8-
gem "commonmarker", "~> 0.14.12"
8+
gem "commonmarker", "~> 0.18.1"
99
gem "rdoc", "~>3.6"
1010
gem "org-ruby", "= 0.9.9"
1111
gem "creole", "~>0.3.6"

HISTORY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 3.0.1 - 2018-10-19
2+
3+
* Remove linguist-detected RMarkdown files from the Markdown renderer [#1237](https://github.com/github/markup/pull/1237)
4+
5+
## 3.0.0 - 2018-10-18
6+
7+
* Allow passing options through to CommonMarker [#1236](https://github.com/github/markup/pull/1236)
8+
* Symlink option is now a keyword arg [#1236](https://github.com/github/markup/pull/1236)
9+
10+
## 2.0.2 - 2018-10-15
11+
12+
* Don't render rmd files as Markdown [#1235](https://github.com/github/markup/pull/1235)
13+
14+
## 2.0.1 - 2018-06-29
15+
16+
* Create anchor for every =item directive in POD files [#1165](https://github.com/github/markup/pull/1165)
17+
118
## 2.0.0 - 2018-01-31
219

320
* Remove filesystem access [#1157](https://github.com/github/markup/pull/1157)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
GitHub Markup
22
=============
33

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:
55

6-
1. This library converts 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. See the [sanitization filter](https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/sanitization_filter.rb) for the full whitelist.
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.
88
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-
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).
9+
1. The HTML is passed through other filters that add special sauce, such as emoji, task lists, named anchors, CDN caching for images, and autolinking.
1010
1. The resulting HTML is rendered on GitHub.com.
1111

1212
Please note that **only the first step** is covered by this gem — the rest happens on GitHub.com. In particular, `markup` itself does no sanitization of the resulting HTML, as it expects that to be covered by whatever pipeline is consuming the HTML.

lib/github-markup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module GitHub
22
module Markup
3-
VERSION = '2.0.0'
3+
VERSION = '3.0.1'
44
Version = VERSION
55
end
66
end

lib/github/commands/pod2html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ my $p = Pod::Simple::XHTML->new;
77
$p->html_header('');
88
$p->html_footer('');
99
$p->perldoc_url_prefix('https://metacpan.org/pod/');
10+
$p->anchor_items(1);
1011
$p->strip_verbatim_indent(sub {
1112
my $lines = shift;
1213
(my $indent = $lines->[0]) =~ s/\S.*//;

lib/github/markup.rb

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,49 @@ module Markups
2121
MARKUP_TEXTILE = :textile
2222
MARKUP_POD6 = :pod6
2323
end
24-
24+
2525
module Markup
2626
extend self
27-
27+
2828
@@markups = {}
2929

3030
def markups
3131
@@markups
3232
end
33-
33+
3434
def markup_impls
3535
markups.values
3636
end
3737

3838
def preload!
39-
markup_impls.each do |markup|
40-
markup.load
41-
end
39+
markup_impls.each(&:load)
4240
end
4341

44-
def render(filename, content, symlink = false)
45-
if impl = renderer(filename, content, symlink)
46-
impl.render(filename, content)
42+
def render(filename, content, symlink: false, options: {})
43+
if (impl = renderer(filename, content, symlink: symlink))
44+
impl.render(filename, content, options: options)
4745
else
4846
content
4947
end
5048
end
51-
49+
5250
def render_s(symbol, content)
53-
if content.nil?
54-
raise ArgumentError, 'Can not render a nil.'
55-
elsif markups.has_key?(symbol)
51+
raise ArgumentError, 'Can not render a nil.' if content.nil?
52+
53+
if markups.key?(symbol)
5654
markups[symbol].render(nil, content)
5755
else
5856
content
5957
end
6058
end
6159

6260
def markup(symbol, gem_name, regexp, languages, opts = {}, &block)
63-
markup_impl(symbol, GemImplementation.new(regexp, languages, gem_name, &block))
61+
impl = GemImplementation.new(regexp, languages, gem_name, &block)
62+
markup_impl(symbol, impl)
6463
end
65-
64+
6665
def markup_impl(symbol, impl)
67-
if markups.has_key?(symbol)
66+
if markups.key?(symbol)
6867
raise ArgumentError, "The '#{symbol}' symbol is already defined."
6968
end
7069
markups[symbol] = impl
@@ -74,25 +73,27 @@ def command(symbol, command, regexp, languages, name, &block)
7473
if File.exist?(file = File.dirname(__FILE__) + "/commands/#{command}")
7574
command = file
7675
end
77-
markup_impl(symbol, CommandImplementation.new(regexp, languages, command, name, &block))
76+
77+
impl = CommandImplementation.new(regexp, languages, command, name, &block)
78+
markup_impl(symbol, impl)
7879
end
7980

80-
def can_render?(filename, content, symlink = false)
81-
!!renderer(filename, content, symlink)
81+
def can_render?(filename, content, symlink: false)
82+
renderer(filename, content, symlink: symlink) != nil
8283
end
8384

84-
def renderer(filename, content, symlink = false)
85-
language = language(filename, content, symlink)
86-
markup_impls.find { |impl|
85+
def renderer(filename, content, symlink: false)
86+
language = language(filename, content, symlink: symlink)
87+
markup_impls.find do |impl|
8788
impl.match?(filename, language)
88-
}
89+
end
8990
end
9091

91-
def language(filename, content, symlink = false)
92-
if defined?(::Linguist)
93-
blob = Linguist::Blob.new(filename, content, symlink: symlink)
94-
return Linguist.detect(blob, allow_empty: true)
95-
end
92+
def language(filename, content, symlink: false)
93+
return unless defined?(::Linguist)
94+
95+
blob = Linguist::Blob.new(filename, content, symlink: symlink)
96+
Linguist.detect(blob, allow_empty: true)
9697
end
9798

9899
# Define markups

lib/github/markup/command_implementation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize(regexp, languages, command, name, &block)
2222
@name = name
2323
end
2424

25-
def render(filename, content)
25+
def render(filename, content, options: {})
2626
rendered = execute(command, content)
2727
rendered = rendered.to_s.empty? ? content : rendered
2828
call_block(rendered, content)

lib/github/markup/gem_implementation.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ def initialize(regexp, languages, gem_name, &renderer)
1212
end
1313

1414
def load
15-
return if @loaded
15+
return if defined?(@loaded) && @loaded
1616
require gem_name
1717
@loaded = true
1818
end
1919

20-
def render(filename, content)
20+
def render(filename, content, options: {})
2121
load
22-
renderer.call(filename, content)
22+
renderer.call(filename, content, options: options)
2323
end
2424

2525
def name

0 commit comments

Comments
 (0)