Skip to content

Commit 6b533e9

Browse files
committed
Merge branch 'master' into align
2 parents 2439ddf + 4690850 commit 6b533e9

32 files changed

+457
-127
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
env:
5+
JRUBY_OPTS: -Xcext.enabled=true
6+
7+
jobs:
8+
build:
9+
name: "Test / Ruby ${{ matrix.ruby }}"
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
ruby:
14+
- "2.4"
15+
- "2.5"
16+
- "2.6"
17+
- "2.7"
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 10
25+
26+
- uses: ruby/setup-ruby@v1
27+
with:
28+
ruby-version: ${{ matrix.ruby }}
29+
bundler-cache: true
30+
31+
- uses: actions/setup-python@v2
32+
with:
33+
# This should match lib/github/markups.rb GitHub::Markups::MARKUP_RST
34+
python-version: '3.x'
35+
36+
- uses: actions/cache@v2
37+
with:
38+
path: ~/.cache/pip
39+
key: ${{ runner.os }}-pip
40+
41+
- name: Install Perl dependencies
42+
run: |
43+
curl -1sLf \
44+
'https://dl.cloudsmith.io/public/nxadm-pkgs/rakudo-pkg/setup.deb.sh' \
45+
| sudo -E bash
46+
sudo apt-get update -qq
47+
sudo apt-get install perl rakudo-pkg
48+
49+
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
50+
sudo cpanm --installdeps --notest Pod::Simple
51+
52+
- name: Install Python dependencies
53+
run: python -m pip install docutils
54+
55+
- name: Run rake
56+
run: |
57+
export PATH=$PATH:/.perl6/bin:/opt/rakudo-pkg/bin
58+
bundle exec rake

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
pkg/
33
.bundle
44
Gemfile.lock
5-
vendor/
65
.project
76
.buildpath
7+
*~

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

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 [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/

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/opensource@github.com
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

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM ubuntu:trusty
2+
3+
RUN apt-get update -qq
4+
RUN apt-get install -y apt-transport-https
5+
6+
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 379CE192D401AB61
7+
RUN echo "deb https://dl.bintray.com/nxadm/rakudo-pkg-debs `lsb_release -cs` main" | tee -a /etc/apt/sources.list.d/rakudo-pkg.list
8+
RUN apt-get update -qq
9+
10+
RUN apt-get install -y \
11+
perl rakudo-pkg curl git build-essential python python-pip \
12+
libssl-dev libreadline-dev zlib1g-dev \
13+
libicu-dev cmake pkg-config
14+
15+
ENV PATH $PATH:/opt/rakudo-pkg/bin
16+
RUN install-zef-as-user && zef install Pod::To::HTML
17+
18+
RUN curl -L http://cpanmin.us | perl - App::cpanminus
19+
RUN cpanm --installdeps --notest Pod::Simple
20+
21+
RUN pip install docutils
22+
23+
ENV PATH $PATH:/root/.rbenv/bin:/root/.rbenv/shims
24+
RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
25+
RUN rbenv install 2.4.1
26+
RUN rbenv global 2.4.1
27+
RUN rbenv rehash
28+
29+
RUN gem install bundler
30+
31+
WORKDIR /data/github-markup
32+
COPY github-markup.gemspec .
33+
COPY Gemfile .
34+
COPY Gemfile.lock .
35+
COPY lib/github-markup.rb lib/github-markup.rb
36+
RUN bundle
37+
38+
ENV LC_ALL en_US.UTF-8
39+
RUN locale-gen en_US.UTF-8

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ 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"
1212
gem "wikicloth", "=0.8.3"
1313
gem "twitter-text", "~> 1.14"
14-
gem "asciidoctor", "= 1.5.6.1"
14+
gem "asciidoctor", "~> 2.0.5"
1515
gem "rake"

HISTORY.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## 4.0.0 - 2021-03-31
2+
3+
* Drop support for Python 2 in RST rendering [#1456](https://github.com/github/markup/pull/1456)
4+
5+
## 3.0.5 - 2020-11-12
6+
7+
* Add commonmarker_exts to commonmarker options [#1268](https://github.com/github/markup/pull/1268)
8+
* Check whether filename is set when rendering Asciidoc. [#1290](https://github.com/github/markup/pull/1290)
9+
10+
## 3.0.4 - 2019-04-03
11+
12+
* Expose options in #render_s [#1249](https://github.com/github/markup/pull/1249)
13+
* Upgrade to Asciidoctor 2.0.x [#1264](https://github.com/github/markup/pull/1264)
14+
15+
## 3.0.3 - 2018-12-17
16+
17+
* Temporarily remove support for POD6 [#1248](https://github.com/github/markup/pull/1248)
18+
19+
## 3.0.2 - 2018-12-12
20+
21+
* Add support for POD6 [#1173](https://github.com/github/markup/pull/1173)
22+
23+
## 3.0.1 - 2018-10-19
24+
25+
* Remove linguist-detected RMarkdown files from the Markdown renderer [#1237](https://github.com/github/markup/pull/1237)
26+
27+
## 3.0.0 - 2018-10-18
28+
29+
* Allow passing options through to CommonMarker [#1236](https://github.com/github/markup/pull/1236)
30+
* Symlink option is now a keyword arg [#1236](https://github.com/github/markup/pull/1236)
31+
32+
## 2.0.2 - 2018-10-15
33+
34+
* Don't render rmd files as Markdown [#1235](https://github.com/github/markup/pull/1235)
35+
136
## 2.0.1 - 2018-06-29
237

338
* Create anchor for every =item directive in POD files [#1165](https://github.com/github/markup/pull/1165)
@@ -41,8 +76,8 @@
4176

4277
### Added
4378

44-
* Re-introduce [#537](https://github.com/github/markup/pull/537) to detect language of markup document
45-
However `github-linguist` is optional and this gem will fallback to extensions for detection.
79+
* Re-introduce [#537](https://github.com/github/markup/pull/537) to detect language of markup document
80+
However `github-linguist` is optional and this gem will fallback to extensions for detection.
4681

4782
[Full changelog](https://github.com/github/markup/compare/v1.4.9...v1.5.0)
4883

README.md

Lines changed: 12 additions & 5 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.
@@ -30,14 +30,21 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
3030
* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::XHTML`
3131
comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
3232

33-
3433
Installation
3534
-----------
3635

3736
```
3837
gem install github-markup
3938
```
4039

40+
or
41+
42+
```
43+
bundle install
44+
```
45+
46+
from this directory.
47+
4148
Usage
4249
-----
4350

github-markup.gemspec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ Gem::Specification.new do |s|
44
s.name = "github-markup"
55
s.version = GitHub::Markup::VERSION
66
s.summary = "The code GitHub uses to render README.markup"
7-
s.description = "This gem is used by GitHub to render any fancy markup such " +
8-
"as Markdown, Textile, Org-Mode, etc. Fork it and add your own!"
7+
s.description = <<~DESC
8+
This gem is used by GitHub to render any fancy markup such as Markdown,
9+
Textile, Org-Mode, etc. Fork it and add your own!
10+
DESC
911
s.authors = ["Chris Wanstrath"]
1012
s.email = "chris@ozmm.org"
1113
s.homepage = "https://github.com/github/markup"
1214
s.license = "MIT"
1315

1416
s.files = `git ls-files`.split($\)
17+
s.files += Dir['vendor/**/*']
1518
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1619
s.test_files = s.files.grep(%r{^(test|spec|features)/})
1720
s.require_paths = %w[lib]
@@ -20,8 +23,8 @@ Gem::Specification.new do |s|
2023
s.add_development_dependency 'activesupport', '~> 4.0'
2124
s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
2225
s.add_development_dependency 'html-pipeline', '~> 1.0'
23-
s.add_development_dependency 'sanitize', '~> 2.1', '>= 2.1.0'
26+
s.add_development_dependency 'sanitize', '>= 4.6.3'
2427
s.add_development_dependency 'nokogiri', '~> 1.8.1'
2528
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
26-
s.add_development_dependency "github-linguist", "~> 6.0"
29+
s.add_development_dependency "github-linguist", ">= 7.1.3"
2730
end

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.1'
3+
VERSION = '4.0.0'
44
Version = VERSION
55
end
66
end

lib/github/commands/pod62html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env perl6
2+
3+
use v6;
4+
5+
slurp.put;

lib/github/commands/rest2html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ except:
4747
import codecs
4848
import io
4949

50-
from docutils import nodes
50+
from docutils import nodes, utils
5151
from docutils.parsers.rst import directives, roles
5252
from docutils.parsers.rst.directives.body import CodeBlock, Directive
5353
from docutils.core import publish_parts
@@ -76,6 +76,35 @@ from docutils import nodes
7676
original_behavior = False # Documents original docutils behavior
7777
github_display = True
7878

79+
def extract_extension_options(field_list, option_spec):
80+
"""
81+
Overrides `utils.extract_extension_options` and inlines
82+
`utils.assemble_option_dict` to make it ignore unknown options passed to
83+
directives (i.e. ``:caption:`` for ``.. code-block:``).
84+
"""
85+
86+
dropped = set()
87+
options = {}
88+
for name, value in utils.extract_options(field_list):
89+
convertor = option_spec.get(name)
90+
if name in options or name in dropped:
91+
raise utils.DuplicateOptionError('duplicate option "%s"' % name)
92+
93+
# silently drop unknown options as long as they are not duplicates
94+
if convertor is None:
95+
dropped.add(name)
96+
continue
97+
98+
# continue as before
99+
try:
100+
options[name] = convertor(value)
101+
except (ValueError, TypeError) as detail:
102+
raise detail.__class__('(option: "%s"; value: %r)\n%s'
103+
% (name, value, ' '.join(detail.args)))
104+
return options
105+
106+
utils.extract_extension_options = extract_extension_options
107+
79108
def unknown_directive(self, type_name):
80109
lineno = self.state_machine.abs_line_number()
81110
indented, indent, offset, blank_finish = \

0 commit comments

Comments
 (0)