github-markup 3.0.4 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73045cfbb77a29fb57c75a078223e159987e9a94f322e3576e25d737947d2d6f
4
- data.tar.gz: 0ad5872c59d15208af1be39b165634f29e7719de546dbaf3f14da47ac21f224f
3
+ metadata.gz: 460b133e720fe08106c84643e1f7b1ca9e2878fbbd3c6cf5865a287f5e5bf92f
4
+ data.tar.gz: 16a8c4145ec42146e945c7cd4cfb3e7819701f099e5de43528b770087ce114b9
5
5
  SHA512:
6
- metadata.gz: 7687ca88baf80f98ba8bba10ba4ce5ab0ac909accfbb54dae340ceebf90f8ba0df36428b32b64c3850f0734b62b4e8573e5c005c85eb33c1d389272d6009805a
7
- data.tar.gz: d33b942a879b556ac9e56913ea287ac64c9d702556a600c8bb8ba3a6c05f11641f846379cbbf504ce65568c98cf05ef1cda5a8d8932dcd99c37b29cea28da7b4
6
+ metadata.gz: 7c6307defe17fe273441c24a615b15840fdfd7a36e2e1585ef7ce84c6bcbf39c6f512a1a354541e713bb957f1f42771423fe06f354f37fe6cd1f4881357980dc
7
+ data.tar.gz: 57fd400b0a38e898eb27da5db1d0335eea594530cce97b5748bb70d6d8594d79e7ec90a72dbfe9e16e85957b93d3da42d7e2805dd57eec28f10dd9afb6153428
@@ -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
data/Gemfile CHANGED
@@ -5,7 +5,9 @@ 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.18.1"
8
+ # using a tag version here because 0.18.3 was not published by the author to encourage users to upgrade.
9
+ # however we want to bump up to this version since this has a security patch
10
+ gem "commonmarker", git: "https://github.com/gjtorikian/commonmarker.git", tag: "v0.18.3"
9
11
  gem "rdoc", "~>3.6"
10
12
  gem "org-ruby", "= 0.9.9"
11
13
  gem "creole", "~>0.3.6"
data/HISTORY.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 4.0.1 - 2022-03-07
2
+ * Update to commonmarker 0.18.3; There isn't a version on RubyGems for this, so this is pointing to a [tag version on GitHub](https://github.com/gjtorikian/commonmarker/blob/v0.18.3/commonmarker.gemspec)
3
+
4
+ ## 4.0.0 - 2021-03-31
5
+
6
+ * Drop support for Python 2 in RST rendering [#1456](https://github.com/github/markup/pull/1456)
7
+
8
+ ## 3.0.5 - 2020-11-12
9
+
10
+ * Add commonmarker_exts to commonmarker options [#1268](https://github.com/github/markup/pull/1268)
11
+ * Check whether filename is set when rendering Asciidoc. [#1290](https://github.com/github/markup/pull/1290)
12
+
1
13
  ## 3.0.4 - 2019-04-03
2
14
 
3
15
  * Expose options in #render_s [#1249](https://github.com/github/markup/pull/1249)
@@ -67,8 +79,8 @@
67
79
 
68
80
  ### Added
69
81
 
70
- * Re-introduce [#537](https://github.com/github/markup/pull/537) to detect language of markup document
71
- However `github-linguist` is optional and this gem will fallback to extensions for detection.
82
+ * Re-introduce [#537](https://github.com/github/markup/pull/537) to detect language of markup document
83
+ However `github-linguist` is optional and this gem will fallback to extensions for detection.
72
84
 
73
85
  [Full changelog](https://github.com/github/markup/compare/v1.4.9...v1.5.0)
74
86
 
@@ -4,8 +4,10 @@ Gem::Specification.new do |s|
4
4
  s.name = "github-markup"
5
5
  s.version = GitHub::Markup::VERSION
6
6
  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
9
11
  s.authors = ["Chris Wanstrath"]
10
12
  s.email = "chris@ozmm.org"
11
13
  s.homepage = "https://github.com/github/markup"
@@ -21,7 +23,7 @@ Gem::Specification.new do |s|
21
23
  s.add_development_dependency 'activesupport', '~> 4.0'
22
24
  s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
23
25
  s.add_development_dependency 'html-pipeline', '~> 1.0'
24
- s.add_development_dependency 'sanitize', '~> 2.1', '>= 2.1.0'
26
+ s.add_development_dependency 'sanitize', '>= 4.6.3'
25
27
  s.add_development_dependency 'nokogiri', '~> 1.8.1'
26
28
  s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
27
29
  s.add_development_dependency "github-linguist", ">= 7.1.3"
@@ -47,7 +47,7 @@ except:
47
47
  import codecs
48
48
  import io
49
49
 
50
- from docutils import nodes
50
+ from docutils import nodes, utils
51
51
  from docutils.parsers.rst import directives, roles
52
52
  from docutils.parsers.rst.directives.body import CodeBlock, Directive
53
53
  from docutils.core import publish_parts
@@ -76,6 +76,35 @@ from docutils import nodes
76
76
  original_behavior = False # Documents original docutils behavior
77
77
  github_display = True
78
78
 
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
+
79
108
  def unknown_directive(self, type_name):
80
109
  lineno = self.state_machine.abs_line_number()
81
110
  indented, indent, offset, blank_finish = \
@@ -6,7 +6,8 @@ module GitHub
6
6
  MARKDOWN_GEMS = {
7
7
  "commonmarker" => proc { |content, options: {}|
8
8
  commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
9
- CommonMarker.render_html(content, commonmarker_opts, [:tagfilter, :autolink, :table, :strikethrough])
9
+ commonmarker_exts = options.fetch(:commonmarker_exts, [:tagfilter, :autolink, :table, :strikethrough])
10
+ CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts)
10
11
  },
11
12
  "github/markdown" => proc { |content, options: {}|
12
13
  GitHub::Markdown.render(content)
@@ -33,20 +33,23 @@ markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["A
33
33
  'idprefix' => '',
34
34
  'idseparator' => '-',
35
35
  'sectanchors' => nil,
36
- 'docname' => File.basename(filename, (extname = File.extname(filename))),
37
- 'docfilesuffix' => extname,
38
- 'outfilesuffix' => extname,
39
36
  'env' => 'github',
40
37
  'env-github' => '',
41
38
  'source-highlighter' => 'html-pipeline'
42
39
  }
40
+ if filename
41
+ attributes['docname'] = File.basename(filename, (extname = File.extname(filename)))
42
+ attributes['docfilesuffix'] = attributes['outfilesuffix'] = extname
43
+ else
44
+ attributes['outfilesuffix'] = '.adoc'
45
+ end
43
46
  Asciidoctor::Compliance.unique_id_start_index = 1
44
47
  Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
45
48
  end
46
49
 
47
50
  command(
48
51
  ::GitHub::Markups::MARKUP_RST,
49
- "python2 -S #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html",
52
+ "python3 #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html",
50
53
  /re?st(\.txt)?/,
51
54
  ["reStructuredText"],
52
55
  "restructuredtext"
data/lib/github-markup.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module GitHub
2
2
  module Markup
3
- VERSION = '3.0.4'
3
+ VERSION = '4.0.1'
4
4
  Version = VERSION
5
5
  end
6
6
  end
data/script/bootstrap CHANGED
@@ -5,4 +5,4 @@ set -e
5
5
  cd $(dirname "$0")/..
6
6
 
7
7
  bundle install
8
- easy_install docutils
8
+ pip3 install docutils
data/test/markup_test.rb CHANGED
@@ -94,7 +94,10 @@ message
94
94
  end
95
95
 
96
96
  def test_rendering_by_symbol
97
- assert_equal '<p><code>test</code></p>', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip
97
+ markup = '`test`'
98
+ result = /<p><code>test<\/code><\/p>/
99
+ assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, markup).strip
100
+ assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_ASCIIDOC, markup).split.join
98
101
  end
99
102
 
100
103
  def test_raises_error_if_command_exits_non_zero
@@ -120,5 +123,11 @@ message
120
123
 
121
124
  assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world")
122
125
  assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})
126
+
127
+ assert_equal "&lt;style>.red{color: red;}&lt;/style>\n", GitHub::Markup.render("test.md", "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE]})
128
+ assert_equal "<style>.red{color: red;}</style>\n", GitHub::Markup.render("test.md", "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]})
129
+
130
+ assert_equal "&lt;style>.red{color: red;}&lt;/style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE]})
131
+ assert_equal "<style>.red{color: red;}</style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]})
123
132
  end
124
133
  end
@@ -39,6 +39,12 @@ The UTF-8 quote character in this table used to cause python to go boom. Now doc
39
39
 
40
40
  python.code('hooray')
41
41
 
42
+ .. code:: python
43
+ :caption: An ignored Sphinx option
44
+ :made-up-option: An ignored made up option
45
+
46
+ python.code('hello world')
47
+
42
48
  .. doctest:: ignored
43
49
 
44
50
  >>> some_function()
@@ -9,13 +9,54 @@
9
9
  </ul>
10
10
  </div>
11
11
  <a name="header-2"></a>
12
- <h2><a href="#id1">Header 2</a></h2>
12
+ <h2><a href="#toc-entry-1">Header 2</a></h2>
13
13
  <ol>
14
14
  <li>Blah blah <code>code</code> blah</li>
15
15
  <li>More <code>code</code>, hooray</li>
16
16
  <li>Somé UTF-8°</li>
17
17
  </ol>
18
18
  <p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.</p>
19
+ <table>
20
+ Things that are Awesome (on a scale of 1-11)
21
+
22
+
23
+
24
+
25
+ <tbody valign="top">
26
+ <tr>
27
+ <td>Thing</td>
28
+ <td>Awesomeness</td>
29
+ </tr>
30
+ <tr>
31
+ <td>Icecream</td>
32
+ <td>7</td>
33
+ </tr>
34
+ <tr>
35
+ <td>Honey Badgers</td>
36
+ <td>10.5</td>
37
+ </tr>
38
+ <tr>
39
+ <td>Nickelback</td>
40
+ <td>-2</td>
41
+ </tr>
42
+ <tr>
43
+ <td>Iron Man</td>
44
+ <td>10</td>
45
+ </tr>
46
+ <tr>
47
+ <td>Iron Man 2</td>
48
+ <td>3</td>
49
+ </tr>
50
+ <tr>
51
+ <td>Tabular Data</td>
52
+ <td>5</td>
53
+ </tr>
54
+ <tr>
55
+ <td>Made up ratings</td>
56
+ <td>11</td>
57
+ </tr>
58
+ </tbody>
59
+ </table>
19
60
  <pre>
20
61
  A block of code
21
62
  </pre>
@@ -23,6 +64,9 @@ A block of code
23
64
  python.code('hooray')
24
65
  </pre>
25
66
  <pre lang="python">
67
+ python.code('hello world')
68
+ </pre>
69
+ <pre lang="python">
26
70
  &gt;&gt;&gt; some_function()
27
71
  'result'
28
72
  </pre>
@@ -62,7 +106,7 @@ python.code('hooray')
62
106
  </a>
63
107
  <img alt="Coverity Scan Build Status" src="https://scan.coverity.com/projects/621/badge.svg">
64
108
  <a name="field-list"></a>
65
- <h2><a href="#id2">Field list</a></h2>
109
+ <h2><a href="#toc-entry-2">Field list</a></h2>
66
110
  <table frame="void" rules="none">
67
111
 
68
112
 
@@ -87,9 +131,7 @@ but no problem!</td>
87
131
  </tr>
88
132
  </tbody>
89
133
  </table>
90
-
91
134
  <p><a href="mailto:someone@somewhere.org">someone@somewhere.org</a></p>
92
-
93
135
  <p>Press <kbd>Ctrl+C</kbd> to quit</p>
94
136
 
95
- <p><strong>RAW HTML!</strong></p> p {color:blue;}
137
+ <p><strong>RAW HTML!</strong></p> p {color:blue;}
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: 3.0.4
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -76,22 +76,16 @@ dependencies:
76
76
  name: sanitize
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '2.1'
82
79
  - - ">="
83
80
  - !ruby/object:Gem::Version
84
- version: 2.1.0
81
+ version: 4.6.3
85
82
  type: :development
86
83
  prerelease: false
87
84
  version_requirements: !ruby/object:Gem::Requirement
88
85
  requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: '2.1'
92
86
  - - ">="
93
87
  - !ruby/object:Gem::Version
94
- version: 2.1.0
88
+ version: 4.6.3
95
89
  - !ruby/object:Gem::Dependency
96
90
  name: nokogiri
97
91
  requirement: !ruby/object:Gem::Requirement
@@ -134,7 +128,8 @@ dependencies:
134
128
  - - ">="
135
129
  - !ruby/object:Gem::Version
136
130
  version: 7.1.3
137
- description: This gem is used by GitHub to render any fancy markup such as Markdown,
131
+ description: |
132
+ This gem is used by GitHub to render any fancy markup such as Markdown,
138
133
  Textile, Org-Mode, etc. Fork it and add your own!
139
134
  email: chris@ozmm.org
140
135
  executables:
@@ -143,9 +138,9 @@ extensions: []
143
138
  extra_rdoc_files: []
144
139
  files:
145
140
  - ".dockerignore"
141
+ - ".github/workflows/ci.yml"
146
142
  - ".gitignore"
147
143
  - ".kick"
148
- - ".travis.yml"
149
144
  - CODE_OF_CONDUCT.md
150
145
  - CONTRIBUTING.md
151
146
  - Dockerfile
@@ -225,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
220
  - !ruby/object:Gem::Version
226
221
  version: '0'
227
222
  requirements: []
228
- rubyforge_project:
229
- rubygems_version: 2.7.6
223
+ rubygems_version: 3.2.9
230
224
  signing_key:
231
225
  specification_version: 4
232
226
  summary: The code GitHub uses to render README.markup
data/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- dist: trusty
2
- sudo: required
3
- language: ruby
4
- rvm:
5
- - 2.1.10
6
- - 2.2.7
7
- - 2.3.4
8
- - 2.4.1
9
- notifications:
10
- email: false
11
- git:
12
- depth: 10
13
- before_install:
14
- - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 379CE192D401AB61
15
- - echo "deb https://dl.bintray.com/nxadm/rakudo-pkg-debs `lsb_release -cs` main" | sudo tee -a /etc/apt/sources.list.d/rakudo-pkg.list
16
- - sudo apt-get update -qq
17
- - sudo apt-get install perl rakudo-pkg
18
- - export PATH=$PATH:/.perl6/bin:/opt/rakudo-pkg/bin
19
- - curl -L http://cpanmin.us | perl - --sudo App::cpanminus
20
- - sudo cpanm --installdeps --notest Pod::Simple
21
- - sudo pip install docutils
22
- cache:
23
- - bundler
24
- - pip
25
- env:
26
- global:
27
- - "JRUBY_OPTS=-Xcext.enabled=true"