Skip to content

Commit c15159b

Browse files
authored
Merge pull request #1814 from github/jk-minified-upgrade-nokogiri
Update nokogiri, nokogiri-diff, rdoc, drop support for Ruby < 3
2 parents a849a12 + 2e6d49d commit c15159b

18 files changed

+2683
-59
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
strategy:
1212
matrix:
1313
ruby:
14-
- "2.4"
15-
- "2.5"
16-
- "2.6"
17-
- "2.7"
14+
- "3.0"
15+
- "3.1"
16+
- "3.2"
17+
- "3.3"
1818
fail-fast: false
1919

2020
steps:

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ pkg/
44
Gemfile.lock
55
.project
66
.buildpath
7-
*~
7+
*~
8+
vendor/

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
source "http://rubygems.org"
22
gemspec
33

4-
gem "posix-spawn", :platforms => :ruby
54
gem "redcarpet", :platforms => :ruby
65
gem "kramdown", :platforms => :jruby
76
gem "RedCloth"
87
# using a tag version here because 0.18.3 was not published by the author to encourage users to upgrade.
98
# however we want to bump up to this version since this has a security patch
109
gem "commonmarker", git: "https://github.com/gjtorikian/commonmarker.git", tag: "v0.18.3"
11-
gem "rdoc", "~>3.6"
10+
gem "rdoc", "~> 6.7.0"
1211
gem "org-ruby", "= 0.9.9"
1312
gem "creole", "~>0.3.6"
1413
gem "wikicloth", "=0.8.3"
1514
gem "twitter-text", "~> 1.14"
1615
gem "asciidoctor", "~> 2.0.5"
1716
gem "rake"
17+
gem "rexml"

HISTORY.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 5.0.0 - 2024-06-17
2+
* Drop support for Ruby versions < 3
3+
* Bump nokogiri from 1.8.1 to 1.16.5
4+
* Bump nokogiri-diff from 0.2.0 to 0.3.0
5+
* Bump rdoc from 3.6 to 6.7.0
6+
* Update CommandImplementation to better support large files (affecting RST and POD6 rendering)
7+
18
## 4.0.2 - 2023-10-10
29
* Add support for .mdx files in markdown
310

github-markup.gemspec

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ Gem::Specification.new do |s|
1313
s.homepage = "https://github.com/github/markup"
1414
s.license = "MIT"
1515

16+
s.required_ruby_version = '>= 3.0.0'
17+
1618
s.files = `git ls-files`.split($\)
17-
s.files += Dir['vendor/**/*']
1819
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1920
s.test_files = s.files.grep(%r{^(test|spec|features)/})
2021
s.require_paths = %w[lib]
@@ -24,7 +25,7 @@ Gem::Specification.new do |s|
2425
s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
2526
s.add_development_dependency 'html-pipeline', '~> 1.0'
2627
s.add_development_dependency 'sanitize', '>= 4.6.3'
27-
s.add_development_dependency 'nokogiri', '~> 1.8.1'
28-
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
28+
s.add_development_dependency 'nokogiri', '~> 1.16.5'
29+
s.add_development_dependency 'nokogiri-diff', '~> 0.3.0'
2930
s.add_development_dependency "github-linguist", ">= 7.1.3"
3031
end

lib/github-markup.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module GitHub
22
module Markup
3-
VERSION = '4.0.2'
3+
VERSION = '5.0.0'
44
Version = VERSION
55
end
66
end

lib/github/markup/command_implementation.rb

+8-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
begin
2-
require "posix-spawn"
3-
rescue LoadError
4-
require "open3"
5-
end
6-
1+
require "open3"
72
require "github/markup/implementation"
83

94

@@ -39,28 +34,13 @@ def call_block(rendered, content)
3934
end
4035
end
4136

42-
if defined?(POSIX::Spawn)
43-
def execute(command, target)
44-
spawn = POSIX::Spawn::Child.new(*command, :input => target)
45-
if spawn.status.success?
46-
sanitize(spawn.out, target.encoding)
47-
else
48-
raise CommandError.new(spawn.err.strip)
49-
end
50-
end
51-
else
52-
def execute(command, target)
53-
output = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
54-
stdin.puts target
55-
stdin.close
56-
if wait_thr.value.success?
57-
stdout.readlines
58-
else
59-
raise CommandError.new(stderr.readlines.join('').strip)
60-
end
61-
end
62-
sanitize(output.join(''), target.encoding)
63-
end
37+
def execute(command, target)
38+
# capture3 blocks until both buffers are written to and the process terminates, but
39+
# it won't allow either buffer to fill up
40+
stdout, stderr, status = Open3.capture3(*command, stdin_data: target)
41+
42+
raise CommandError.new(stderr) unless status.success?
43+
sanitize(stdout, target.encoding)
6444
end
6545

6646
def sanitize(input, encoding)

test/markup_test.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def call
6666
f.close_write
6767
f.read
6868
end
69+
70+
if ENV['UPDATE']
71+
File.open(expected_file, 'w') { |f| f.write actual }
72+
end
73+
6974
assert_html_equal expected, actual, <<message
7075
#{File.basename expected_file}'s contents are not html equal to output:
7176
#{diff}
@@ -106,7 +111,7 @@ def test_raises_error_if_command_exits_non_zero
106111
begin
107112
GitHub::Markup.render('README.java', "stop swallowing errors", symlink: false)
108113
rescue GitHub::Markup::CommandError => e
109-
assert_equal "failure message", e.message
114+
assert_equal "failure message", e.message.strip
110115
else
111116
fail "an exception was expected but was not raised"
112117
end

test/markups/README.asciidoc.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ <h2>Another Section</h2>
5959
<p>content</p>
6060
</div>
6161
</div>
62-
</div>
62+
</div>
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
22
<p>This test verifies the author can disable the document title by adding <code>:!showtitle:</code> to the document header.</p>
3-
</div>
3+
</div>

test/markups/README.litcoffee.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ <h2>Literate CoffeeScript Test</h2>
5252
</ul>
5353
<p>Tabs work too:</p>
5454
<p>test "tabbed code", -&gt;
55-
ok yes</p>
55+
ok yes</p>

0 commit comments

Comments
 (0)