github-markup 5.0.1 → 6.1.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: a16f615db76eeec528d2740f8f417c3b4e744d9cbd60f2e48c4de0ac9e154c8c
4
- data.tar.gz: bbf5e23d4b3f3e709db7c21b3dbb362f1cf1da4d84bcad450169abf263733bf0
3
+ metadata.gz: ff91a38bd9532efbc68ffc793d856a1f5af72e1831d900ed8385acc0147a9701
4
+ data.tar.gz: ada0dc4fabe2ee882f561de3ce4b793d7b57dabb93970feaf95de78631630686
5
5
  SHA512:
6
- metadata.gz: 499115c0d8552ab3d59a13b9b5d34fa04b462afd5b56381269aadfb3ff48693409e43a087313402257514d75674b7209ccc82f5887bea75815573d8441c6ec4c
7
- data.tar.gz: f7f6fb200d33f3e7b86c11eddcf01e5e225971574c1f313215512aae19e66c0561c282ba225e4ac2da49d11a22063c5da4036449f3606ccf11cbffad70b1443f
6
+ metadata.gz: 0c535823d7f8d1628c6d26e88ade186062481ccac28205acc1db60d586fea0fe63f2c922dc51f63eb48d66b64e7e49054c84f19d22b5be15a9a204a4d9ab8328
7
+ data.tar.gz: 1edab0acae8bbd2f7eb2d46d5932643b611372412112d8f2b5203b51ee67f0fd3c288eeb61888557b8e2bb4ff77df393dc1e166d5e36b13837352653af057c34
@@ -0,0 +1,28 @@
1
+ ---
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: 'bundler'
5
+ directory: '/'
6
+ schedule:
7
+ interval: 'weekly'
8
+ commit-message:
9
+ prefix: 'chore(deps)'
10
+ groups:
11
+ dependencies:
12
+ applies-to: version-updates
13
+ update-types:
14
+ - 'minor'
15
+ - 'patch'
16
+ - package-ecosystem: 'github-actions'
17
+ directory: '/'
18
+ schedule:
19
+ interval: 'weekly'
20
+ commit-message:
21
+ prefix: 'chore(deps)'
22
+ groups:
23
+ dependencies:
24
+ applies-to: version-updates
25
+ update-types:
26
+ - 'minor'
27
+ - 'patch'
28
+
@@ -4,36 +4,57 @@ on: [push, pull_request]
4
4
  env:
5
5
  JRUBY_OPTS: -Xcext.enabled=true
6
6
 
7
+ permissions:
8
+ contents: read
9
+
7
10
  jobs:
8
11
  build:
9
- name: "Test / Ruby ${{ matrix.ruby }}"
12
+ name: "Test / Ruby ${{ matrix.ruby }} / RDoc ${{ matrix.rdoc }} / CommonMarker ${{ matrix.commonmarker }}"
10
13
  runs-on: ubuntu-latest
14
+ env:
15
+ RDOC_VERSION: "~> ${{ matrix.rdoc }}"
16
+ COMMONMARKER_VERSION: "${{ matrix.commonmarker }}"
11
17
  strategy:
12
18
  matrix:
19
+ commonmarker:
20
+ - "~> 2.8.2"
21
+ rdoc:
22
+ - "7.2.0"
13
23
  ruby:
14
- - "3.0"
15
- - "3.1"
16
- - "3.2"
17
24
  - "3.3"
25
+ - "3.4"
26
+ - "4.0"
27
+ include:
28
+ - ruby: "4.0"
29
+ rdoc: "8.0"
30
+ commonmarker: "~> 2.8.2"
31
+ - ruby: "3.4"
32
+ rdoc: "7.2.0"
33
+ commonmarker: "0.23.12"
18
34
  fail-fast: false
19
35
 
20
36
  steps:
21
37
  - name: Checkout
22
- uses: actions/checkout@v2
38
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23
39
  with:
24
40
  fetch-depth: 10
41
+ persist-credentials: false
25
42
 
26
- - uses: ruby/setup-ruby@v1
43
+ - uses: ruby/setup-ruby@651ff0d62c5c79bed6d53ec518387aae20e72c1a # v1.329.0
27
44
  with:
28
45
  ruby-version: ${{ matrix.ruby }}
29
- bundler-cache: true
46
+ bundler-cache: ${{ matrix.rdoc == '7.2.0' && matrix.commonmarker == '~> 2.8.2' }}
47
+
48
+ - name: Resolve overridden parser dependencies
49
+ if: matrix.rdoc != '7.2.0' || matrix.commonmarker != '~> 2.8.2'
50
+ run: bundle update commonmarker rdoc
30
51
 
31
- - uses: actions/setup-python@v2
52
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
32
53
  with:
33
- # This should match lib/github/markups.rb GitHub::Markups::MARKUP_RST
34
- python-version: '3.x'
54
+ # Required by lib/github/commands/rest2html (RST rendering)
55
+ python-version: "3.x"
35
56
 
36
- - uses: actions/cache@v2
57
+ - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
37
58
  with:
38
59
  path: ~/.cache/pip
39
60
  key: ${{ runner.os }}-pip
@@ -46,11 +67,13 @@ jobs:
46
67
  sudo apt-get update -qq
47
68
  sudo apt-get install perl rakudo-pkg
48
69
 
49
- curl -L http://cpanmin.us | perl - --sudo App::cpanminus
70
+ curl -fsSL https://cpanmin.us | perl - --sudo App::cpanminus
50
71
  sudo cpanm --installdeps --notest Pod::Simple
51
72
 
52
73
  - name: Install Python dependencies
53
- run: python -m pip install docutils
74
+ run: |
75
+ echo 'docutils==0.22.4 --hash=sha256:d0013f540772d1420576855455d050a2180186c91c15779301ac2ccb3eeb68de' > /tmp/requirements.txt
76
+ python -m pip install --require-hashes --no-deps -r /tmp/requirements.txt
54
77
 
55
78
  - name: Run rake
56
79
  run: |
@@ -0,0 +1,27 @@
1
+ name: Mark stale issues and pull requests
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 12 * * *"
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ issues: write
12
+ pull-requests: write
13
+
14
+ steps:
15
+ - uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
16
+ with:
17
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
18
+ stale-issue-message: >
19
+ This issue has been automatically marked as stale because it has not
20
+ had recent activity. It will be closed if no further activity occurs.
21
+ Thank you for your contributions.
22
+ stale-pr-message: >
23
+ This pull request has been automatically marked as stale because it has not
24
+ had recent activity. It will be closed if no further activity occurs.
25
+ Thank you for your contributions.
26
+ exempt-issue-labels: keep
27
+ exempt-pr-labels: keep
data/.gitignore CHANGED
@@ -1,9 +1,11 @@
1
1
  *.pyc
2
2
  pkg/
3
3
  .bundle
4
- Gemfile.lock
5
4
  .project
6
5
  .buildpath
7
6
  *~
8
7
  vendor/
9
8
  .DS_Store
9
+ .venv
10
+ venv
11
+ coverage/
data/CONTRIBUTING.md CHANGED
@@ -37,6 +37,18 @@ To run the tests:
37
37
 
38
38
  If nothing complains, congratulations!
39
39
 
40
+ CI tests RDoc 7.2 and 8.x. To test RDoc 8.x locally:
41
+
42
+ $ RDOC_VERSION='~> 8.0' bundle update rdoc
43
+ $ RDOC_VERSION='~> 8.0' bundle exec rake
44
+
45
+ CI also tests CommonMarker 0.23.12. To run the full suite with the legacy parser:
46
+
47
+ $ COMMONMARKER_VERSION=0.23.12 bundle update commonmarker
48
+ $ COMMONMARKER_VERSION=0.23.12 bundle exec rake
49
+
50
+ Run these commands in a separate checkout to keep the default lockfile unchanged. You can combine `COMMONMARKER_VERSION` and `RDOC_VERSION` to test both overrides.
51
+
40
52
  ## Releasing a new version
41
53
 
42
54
  If you are the current maintainer of this gem:
data/Gemfile CHANGED
@@ -1,17 +1,14 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
4
  gem "redcarpet", :platforms => :ruby
5
5
  gem "kramdown", :platforms => :jruby
6
6
  gem "RedCloth"
7
- # using a tag version here because 0.18.3 was not published by the author to encourage users to upgrade.
8
- # however we want to bump up to this version since this has a security patch
9
- gem "commonmarker", git: "https://github.com/gjtorikian/commonmarker.git", tag: "v0.18.3"
10
- gem "rdoc", "~> 6.7.0"
11
- gem "org-ruby", "= 0.9.9"
12
- gem "creole", "~>0.3.6"
7
+ gem "commonmarker", ENV.fetch("COMMONMARKER_VERSION", "~> 2.8.2")
8
+ gem "rdoc", ENV.fetch("RDOC_VERSION", "~> 7.2.0")
9
+ gem "org-ruby", "0.9.12"
10
+ gem "creole", "~>0.5.0"
13
11
  gem "wikicloth", "=0.8.3"
14
12
  gem "twitter-text", "~> 1.14"
15
- gem "asciidoctor", "~> 2.0.5"
16
- gem "rake"
13
+ gem "asciidoctor", "~> 2.0.26"
17
14
  gem "rexml"
data/Gemfile.lock ADDED
@@ -0,0 +1,162 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ github-markup (6.1.1)
5
+ rdoc (< 9)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ RedCloth (4.3.4)
11
+ activesupport (8.1.3)
12
+ base64
13
+ bigdecimal
14
+ concurrent-ruby (~> 1.0, >= 1.3.1)
15
+ connection_pool (>= 2.2.5)
16
+ drb
17
+ i18n (>= 1.6, < 2)
18
+ json
19
+ logger (>= 1.4.2)
20
+ minitest (>= 5.1)
21
+ securerandom (>= 0.3)
22
+ tzinfo (~> 2.0, >= 2.0.5)
23
+ uri (>= 0.13.1)
24
+ asciidoctor (2.0.26)
25
+ base64 (0.3.0)
26
+ bigdecimal (4.1.2)
27
+ builder (3.3.0)
28
+ cgi (0.5.1)
29
+ charlock_holmes (0.7.9)
30
+ commonmarker (2.8.2)
31
+ rb_sys (~> 0.9)
32
+ commonmarker (2.8.2-aarch64-linux)
33
+ commonmarker (2.8.2-arm-linux)
34
+ commonmarker (2.8.2-arm64-darwin)
35
+ commonmarker (2.8.2-x86_64-darwin)
36
+ commonmarker (2.8.2-x86_64-linux)
37
+ concurrent-ruby (1.3.6)
38
+ connection_pool (3.0.2)
39
+ creole (0.5.0)
40
+ date (3.5.1)
41
+ docile (1.4.1)
42
+ drb (2.2.3)
43
+ erb (6.0.4)
44
+ expression_parser (0.9.0)
45
+ github-linguist (9.5.0)
46
+ cgi
47
+ charlock_holmes (~> 0.7.7)
48
+ mini_mime (~> 1.0)
49
+ rugged (~> 1.0)
50
+ html-pipeline (3.2.4)
51
+ selma (~> 0.4)
52
+ zeitwerk (~> 2.5)
53
+ htmlentities (4.3.4)
54
+ i18n (1.14.8)
55
+ concurrent-ruby (~> 1.0)
56
+ json (2.19.5)
57
+ logger (1.7.0)
58
+ mini_mime (1.1.5)
59
+ mini_portile2 (2.8.9)
60
+ minitest (6.0.6)
61
+ drb (~> 2.0)
62
+ prism (~> 1.5)
63
+ nokogiri (1.19.3)
64
+ mini_portile2 (~> 2.8.2)
65
+ racc (~> 1.4)
66
+ nokogiri (1.19.3-aarch64-linux-gnu)
67
+ racc (~> 1.4)
68
+ nokogiri (1.19.3-arm-linux-gnu)
69
+ racc (~> 1.4)
70
+ nokogiri (1.19.3-arm64-darwin)
71
+ racc (~> 1.4)
72
+ nokogiri (1.19.3-x86_64-darwin)
73
+ racc (~> 1.4)
74
+ nokogiri (1.19.3-x86_64-linux-gnu)
75
+ racc (~> 1.4)
76
+ nokogiri-diff (0.3.0)
77
+ nokogiri (~> 1.5)
78
+ tdiff (~> 0.4)
79
+ org-ruby (0.9.12)
80
+ rubypants (~> 0.2)
81
+ prism (1.9.0)
82
+ psych (5.3.1)
83
+ date
84
+ stringio
85
+ racc (1.8.1)
86
+ rake (13.4.2)
87
+ rake-compiler-dock (1.12.0)
88
+ rb_sys (0.9.128)
89
+ rake-compiler-dock (= 1.12.0)
90
+ rdoc (7.2.0)
91
+ erb
92
+ psych (>= 4.0.0)
93
+ tsort
94
+ redcarpet (3.6.1)
95
+ rexml (3.4.4)
96
+ rubypants (0.7.1)
97
+ rugged (1.9.0)
98
+ securerandom (0.4.1)
99
+ selma (0.5.0)
100
+ rb_sys (~> 0.9)
101
+ selma (0.5.0-aarch64-linux)
102
+ selma (0.5.0-arm-linux)
103
+ selma (0.5.0-arm64-darwin)
104
+ selma (0.5.0-x86_64-darwin)
105
+ selma (0.5.0-x86_64-linux)
106
+ simplecov (0.22.0)
107
+ docile (~> 1.1)
108
+ simplecov-html (~> 0.11)
109
+ simplecov_json_formatter (~> 0.1)
110
+ simplecov-html (0.13.2)
111
+ simplecov_json_formatter (0.1.4)
112
+ stringio (3.2.0)
113
+ tdiff (0.4.0)
114
+ tsort (0.2.0)
115
+ twitter-text (1.14.7)
116
+ unf (~> 0.1.0)
117
+ tzinfo (2.0.6)
118
+ concurrent-ruby (~> 1.0)
119
+ unf (0.1.4)
120
+ unf_ext
121
+ unf_ext (0.0.9.1)
122
+ uri (1.1.1)
123
+ wikicloth (0.8.3)
124
+ builder
125
+ expression_parser
126
+ htmlentities
127
+ nokogiri
128
+ twitter-text
129
+ zeitwerk (2.8.2)
130
+
131
+ PLATFORMS
132
+ aarch64-linux
133
+ arm-linux
134
+ arm64-darwin
135
+ x86-linux
136
+ x86_64-darwin
137
+ x86_64-linux
138
+
139
+ DEPENDENCIES
140
+ RedCloth
141
+ activesupport (~> 8.1.3)
142
+ asciidoctor (~> 2.0.26)
143
+ commonmarker (~> 2.8.2)
144
+ creole (~> 0.5.0)
145
+ github-linguist (>= 7.1.3)
146
+ github-markup!
147
+ html-pipeline (~> 3.2)
148
+ kramdown
149
+ minitest (~> 6.0, >= 5.4.3)
150
+ nokogiri (~> 1.19.2)
151
+ nokogiri-diff (~> 0.3.0)
152
+ org-ruby (= 0.9.12)
153
+ rake (~> 13)
154
+ rdoc (~> 7.2.0)
155
+ redcarpet
156
+ rexml
157
+ simplecov (~> 0.22)
158
+ twitter-text (~> 1.14)
159
+ wikicloth (= 0.8.3)
160
+
161
+ BUNDLED WITH
162
+ 2.3.26
data/HISTORY.md CHANGED
@@ -1,3 +1,89 @@
1
+ ## 6.1.1 (unreleased)
2
+
3
+ ### Bug Fixes
4
+
5
+ * I restored the CommonMarker 0.x API without requiring a parser upgrade. Existing 0.x installations retain their rendering flags, extension validation, and output behavior.
6
+ * I retained CommonMarker 2.x support with its existing option behavior.
7
+ * I added full-suite CI coverage for CommonMarker 0.23.12 alongside the default 2.8.2 dependency.
8
+
9
+ The RDoc 8 and reStructuredText fixes listed below remain included.
10
+
11
+ ## 6.1.0 - 2026-10-16 (withdrawn)
12
+
13
+ I withdrew this release because it required a CommonMarker upgrade for existing 0.x installations. The `v6.1.0` tag remains available for traceability.
14
+
15
+ ### Compatibility Changes
16
+
17
+ * Require commonmarker 2.x when using the CommonMarker renderer; upgrade existing commonmarker 0.x installations [#2059](https://github.com/github/markup/pull/2059).
18
+ * Accept `VALIDATE_UTF8`, `LIBERAL_HTML_TAG`, `TABLE_PREFER_STYLE_ATTRIBUTES`, and `STRIKETHROUGH_DOUBLE_TILDE` without applying them [#2059](https://github.com/github/markup/pull/2059).
19
+ * Preserve soft line breaks with `NOBREAKS` instead of converting them to spaces [#2059](https://github.com/github/markup/pull/2059).
20
+ * Apply `HARDBREAKS` and `NOBREAKS` in their supplied order; the last flag wins, replacing the old `HARDBREAKS` precedence [#2059](https://github.com/github/markup/pull/2059).
21
+
22
+ ### Bug Fixes
23
+
24
+ * Support RDoc 8 formatter initialization and declare `rdoc < 9` as a runtime dependency [#2109](https://github.com/github/markup/pull/2109), [#2104](https://github.com/github/markup/pull/2104).
25
+ * Restore reStructuredText section and table-of-contents anchors with docutils 0.18 and later [#2081](https://github.com/github/markup/pull/2081), [#2087](https://github.com/github/markup/pull/2087).
26
+
27
+ ### Development
28
+
29
+ * Update development dependencies to commonmarker 2.8.2, html-pipeline 3.2, minitest 6, and activesupport 8.1.
30
+ * Require 100% measured line and branch coverage and load gem metadata without loading renderers [#2072](https://github.com/github/markup/pull/2072).
31
+
32
+ ## 7.0.0 - 2026-10-15 (withdrawn)
33
+
34
+ I withdrew this release on 2026-10-16. The `v7.0.0` tag remains available for traceability.
35
+
36
+ ### Breaking
37
+
38
+ * Require commonmarker 2.x when using the CommonMarker renderer; upgrade existing commonmarker 0.x installations [#2059](https://github.com/github/markup/pull/2059).
39
+ * Accept `VALIDATE_UTF8`, `LIBERAL_HTML_TAG`, `TABLE_PREFER_STYLE_ATTRIBUTES`, and `STRIKETHROUGH_DOUBLE_TILDE` without applying them [#2059](https://github.com/github/markup/pull/2059).
40
+ * Preserve soft line breaks with `NOBREAKS` instead of converting them to spaces [#2059](https://github.com/github/markup/pull/2059).
41
+ * Apply `HARDBREAKS` and `NOBREAKS` in their supplied order; the last flag wins, replacing the old `HARDBREAKS` precedence [#2059](https://github.com/github/markup/pull/2059).
42
+
43
+ ### Bug Fixes
44
+
45
+ * Support RDoc 8 formatter initialization and declare `rdoc < 9` as a runtime dependency [#2109](https://github.com/github/markup/pull/2109), [#2104](https://github.com/github/markup/pull/2104).
46
+ * Restore reStructuredText section and table-of-contents anchors with docutils 0.18 and later [#2081](https://github.com/github/markup/pull/2081), [#2087](https://github.com/github/markup/pull/2087).
47
+
48
+ ### Development
49
+
50
+ * Update development dependencies to commonmarker 2.8.2, html-pipeline 3.2, minitest 6, and activesupport 8.1.
51
+ * Require 100% measured line and branch coverage and load gem metadata without loading renderers [#2072](https://github.com/github/markup/pull/2072).
52
+
53
+ ## 6.0.0 - 2026-05-04
54
+
55
+ ### Breaking
56
+
57
+ * Drop support for Ruby < 3.3 (Ruby 3.1 EOL March 2025, Ruby 3.2 EOL March 2026)
58
+
59
+ ### Security
60
+
61
+ * Use HTTPS for cpanminus download in CI to prevent MITM attacks [#2050](https://github.com/github/markup/pull/2050)
62
+ * Bump nokogiri to >= 1.19.1 to fix GHSA-wx95-c6cv-8532
63
+ * Harden CI pip install with `--require-hashes --no-deps` [#2048](https://github.com/github/markup/pull/2048)
64
+ * Use HTTPS for RubyGems source URL in Gemfile [#1854](https://github.com/github/markup/pull/1854)
65
+ * Add explicit `contents: read` permissions to CI workflow [#1855](https://github.com/github/markup/pull/1855)
66
+ * Bump rexml from 3.3.0 to 3.3.9 (multiple security fixes)
67
+
68
+ ### Bug Fixes
69
+
70
+ * Fix RST section ID rendering to iterate all anchors instead of only the first [040f91d](https://github.com/github/markup/commit/040f91d)
71
+
72
+ ### Documentation
73
+
74
+ * Fix spelling errors in codebase [#1479](https://github.com/github/markup/pull/1479)
75
+ * Fix broken Textile language link in README [#1703](https://github.com/github/markup/pull/1703)
76
+
77
+ ### Infrastructure
78
+
79
+ * Remove legacy Dockerfile and .dockerignore (Ubuntu Trusty, non-functional) [#2048](https://github.com/github/markup/pull/2048)
80
+ * Update CI test matrix: drop Ruby 3.2, add Ruby 4.0 (now testing 3.3, 3.4, 4.0)
81
+ * Bump nokogiri to 1.19.2, activesupport to 7.2.3.1
82
+ * Bump github-linguist from 7.30.0 to 9.1.0, then to 9.3.0
83
+ * Pin all GitHub Actions to commit SHAs for supply chain hardening
84
+ * Add Dependabot configuration for automated dependency updates
85
+ * Various Dependabot bumps for CI actions (ruby/setup-ruby, actions/checkout, actions/cache, actions/setup-python, actions/stale)
86
+
1
87
  ## 5.0.1 - 2024-06-17
2
88
  * Bump activesupport from 4.0 to 7.1.3.4
3
89
 
data/README.md CHANGED
@@ -20,8 +20,8 @@ The following markups are supported. The dependencies listed are required if
20
20
  you wish to run the library. You can also run `script/bootstrap` to fetch them all.
21
21
 
22
22
  * [.markdown, .mdown, .mkdn, .md](http://daringfireball.net/projects/markdown/) -- `gem install commonmarker` (https://github.com/gjtorikian/commonmarker)
23
- * [.textile](https://www.promptworks.com/textile) -- `gem install RedCloth` (https://github.com/jgarber/redcloth)
24
- * [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc -v 3.6.1`
23
+ * [.textile](https://textile-lang.com/) -- `gem install RedCloth` (https://github.com/jgarber/redcloth)
24
+ * [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc`
25
25
  * [.org](http://orgmode.org/) -- `gem install org-ruby` (https://github.com/wallyqs/org-ruby)
26
26
  * [.creole](http://wikicreole.org/) -- `gem install creole` (https://github.com/larsch/creole)
27
27
  * [.mediawiki, .wiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` (https://github.com/nricciar/wikicloth)
@@ -48,6 +48,8 @@ from this directory.
48
48
  Usage
49
49
  -----
50
50
 
51
+ Markdown rendering supports CommonMarker 0.x and 2.x. Keep the installed version to retain that parser's option behavior. Extensions follow the installed parser; 2.x-only extensions remain unavailable with 0.x.
52
+
51
53
  Basic form:
52
54
 
53
55
  ```ruby
@@ -72,6 +74,17 @@ require 'github/markup'
72
74
  GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "* One\n* Two")
73
75
  ```
74
76
 
77
+ Local Development
78
+ -----------------
79
+
80
+ ```sh
81
+ python3 -m venv .venv
82
+ source .venv/bin/activate
83
+ cd script
84
+ ./bootstrap
85
+ ```
86
+
87
+ Set `COMMONMARKER_VERSION` to override the development bundle's default `~> 2.8.2` requirement. See [Testing](CONTRIBUTING.md#testing) for parser version commands.
75
88
 
76
89
  Contributing
77
90
  ------------
@@ -1,8 +1,11 @@
1
- require File.expand_path("../lib/github-markup", __FILE__)
1
+ version_file = File.expand_path("../lib/github-markup.rb", __FILE__)
2
+ version_match = File.read(version_file).match(/VERSION = ['"]([^'"]+)['"]/)
3
+ raise "Could not find VERSION in #{version_file}" unless version_match
4
+ version = version_match[1]
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = "github-markup"
5
- s.version = GitHub::Markup::VERSION
8
+ s.version = version
6
9
  s.summary = "The code GitHub uses to render README.markup"
7
10
  s.description = <<~DESC
8
11
  This gem is used by GitHub to render any fancy markup such as Markdown,
@@ -13,19 +16,21 @@ Gem::Specification.new do |s|
13
16
  s.homepage = "https://github.com/github/markup"
14
17
  s.license = "MIT"
15
18
 
16
- s.required_ruby_version = '>= 3.0.0'
19
+ s.required_ruby_version = '>= 3.3.0'
17
20
 
18
21
  s.files = `git ls-files`.split($\)
19
22
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
23
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
24
  s.require_paths = %w[lib]
22
25
 
23
- s.add_development_dependency 'rake', '~> 12'
24
- s.add_development_dependency 'activesupport', '~> 7.1.3.4'
25
- s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
26
- s.add_development_dependency 'html-pipeline', '~> 1.0'
27
- s.add_development_dependency 'sanitize', '>= 4.6.3'
28
- s.add_development_dependency 'nokogiri', '~> 1.16.5'
26
+ s.add_dependency 'rdoc', '< 9'
27
+
28
+ s.add_development_dependency 'rake', '~> 13'
29
+ s.add_development_dependency 'activesupport', '~> 8.1.3'
30
+ s.add_development_dependency 'minitest', '>= 5.4.3', '~> 6.0'
31
+ s.add_development_dependency 'html-pipeline', '~> 3.2'
32
+ s.add_development_dependency 'nokogiri', '~> 1.19.2'
29
33
  s.add_development_dependency 'nokogiri-diff', '~> 0.3.0'
30
34
  s.add_development_dependency "github-linguist", ">= 7.1.3"
35
+ s.add_development_dependency 'simplecov', '~> 0.22'
31
36
  end
@@ -160,6 +160,7 @@ SETTINGS = {
160
160
  'syntax_highlight': 'none',
161
161
  'math_output': 'latex',
162
162
  'field_name_limit': 50,
163
+ 'auto_id_prefix': 'id',
163
164
  }
164
165
 
165
166
  default_highlight_language = None
@@ -199,8 +200,8 @@ class GitHubHTMLTranslator(HTMLTranslator):
199
200
  # see also: http://bit.ly/NHtyRx
200
201
  # the a is to support ::contents with ::sectnums: http://git.io/N1yC
201
202
  def visit_section(self, node):
202
- id_attribute = node.attributes['ids'][0]
203
- self.body.append('<a name="%s"></a>\n' % id_attribute)
203
+ for id_attribute in node.attributes['ids']:
204
+ self.body.append('<a name="%s"></a>\n' % id_attribute)
204
205
  self.section_level += 1
205
206
 
206
207
  def depart_section(self, node):
@@ -5,9 +5,93 @@ module GitHub
5
5
  class Markdown < Implementation
6
6
  MARKDOWN_GEMS = {
7
7
  "commonmarker" => proc { |content, options: {}|
8
- commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
9
- commonmarker_exts = options.fetch(:commonmarker_exts, [:tagfilter, :autolink, :table, :strikethrough])
10
- CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts)
8
+ legacy_opts = options.fetch(:commonmarker_opts, [])
9
+ legacy_exts = options.fetch(
10
+ :commonmarker_exts,
11
+ [:tagfilter, :autolink, :table, :strikethrough],
12
+ )
13
+
14
+ unless defined?(::Commonmarker) && ::Commonmarker.respond_to?(:to_html)
15
+ next ::CommonMarker.render_html(content, [:GITHUB_PRE_LANG] + legacy_opts, legacy_exts)
16
+ end
17
+
18
+ parse_options = {}
19
+ # commonmarker 2.x changes several render defaults that diverge from cmark-gfm 0.x:
20
+ # - hardbreaks defaults to true in 2.x but was false in 0.x.
21
+ # - escaped_char_spans defaults to true in 2.x and wraps backslash-escaped chars in
22
+ # <span data-escaped-char>; 0.x emitted bare characters.
23
+ # - gfm_quirks defaults to false in 2.x; 0.x (cmark-gfm) always had the quirk on,
24
+ # which collapses ****foo**** to <strong>foo</strong> instead of nesting.
25
+ # - github_pre_lang defaults to true in 2.x; set explicitly to match the legacy contract.
26
+ render_options = {
27
+ github_pre_lang: true,
28
+ hardbreaks: false,
29
+ escaped_char_spans: false,
30
+ gfm_quirks: true,
31
+ }
32
+ extension_options = {}
33
+
34
+ legacy_opts.each do |opt|
35
+ case opt
36
+ when :DEFAULT then nil
37
+ when :SOURCEPOS then render_options[:sourcepos] = true
38
+ when :HARDBREAKS then render_options[:hardbreaks] = true
39
+ when :NOBREAKS then render_options[:hardbreaks] = false
40
+ when :SMART then parse_options[:smart] = true
41
+ when :GITHUB_PRE_LANG then render_options[:github_pre_lang] = true
42
+ when :UNSAFE then render_options[:unsafe] = true
43
+ when :FOOTNOTES then extension_options[:footnotes] = true
44
+ when :FULL_INFO_STRING then render_options[:full_info_string] = true
45
+ # The legacy options below existed in cmark-gfm 0.x but have no direct commonmarker
46
+ # 2.x equivalent. Accept them so existing callers don't break, but they have no effect:
47
+ # :VALIDATE_UTF8 / :LIBERAL_HTML_TAG - enforced at the Rust type layer in 2.x.
48
+ # :TABLE_PREFER_STYLE_ATTRIBUTES - no 2.x render knob for inline table styles.
49
+ # :STRIKETHROUGH_DOUBLE_TILDE - 2.x always accepts both single and double tilde.
50
+ when :VALIDATE_UTF8, :LIBERAL_HTML_TAG,
51
+ :TABLE_PREFER_STYLE_ATTRIBUTES, :STRIKETHROUGH_DOUBLE_TILDE
52
+ nil
53
+ else
54
+ raise ArgumentError, "unknown commonmarker option: #{opt.inspect}"
55
+ end
56
+ end
57
+
58
+ legacy_exts.each do |ext|
59
+ case ext
60
+ when :strikethrough, :tagfilter, :autolink, :table, :tasklist,
61
+ :shortcodes, :footnotes, :multiline_block_quotes,
62
+ :math_dollars, :math_code, :wikilinks_title_after_pipe,
63
+ :wikilinks_title_before_pipe, :underline, :subscript, :spoiler,
64
+ :greentext, :alerts, :description_lists
65
+ extension_options[ext] = true
66
+ when :header_ids
67
+ # header_ids takes a string prefix in 2.x rather than a boolean. An empty prefix
68
+ # enables anchor generation for the symbol-based commonmarker_exts option.
69
+ extension_options[:header_ids] = ""
70
+ else
71
+ raise ArgumentError, "unknown commonmarker extension: #{ext.inspect}"
72
+ end
73
+ end
74
+
75
+ # CommonMarker 2.x enables more extensions by default than this wrapper does.
76
+ # Disable unrequested defaults to preserve the wrapper's extension choices.
77
+ [:strikethrough, :tagfilter, :autolink, :table, :tasklist, :shortcodes].each do |ext|
78
+ extension_options[ext] = false unless extension_options[ext]
79
+ end
80
+
81
+ # header_ids is enabled by default in commonmarker 2.x (it injects anchor tags inside
82
+ # every heading). The legacy 0.x wrapper never enabled it implicitly, so disable it
83
+ # unless the caller explicitly requested it.
84
+ extension_options[:header_ids] = nil unless extension_options.key?(:header_ids)
85
+
86
+ Commonmarker.to_html(
87
+ content,
88
+ options: {
89
+ parse: parse_options,
90
+ render: render_options,
91
+ extension: extension_options,
92
+ },
93
+ plugins: {syntax_highlighter: nil},
94
+ )
11
95
  },
12
96
  "github/markdown" => proc { |content, options: {}|
13
97
  GitHub::Markdown.render(content)