Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nokogiri, nokogiri-diff, rdoc, drop support for Ruby < 3 #1814

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
strategy:
matrix:
ruby:
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
fail-fast: false

steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pkg/
Gemfile.lock
.project
.buildpath
*~
*~
vendor/
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
source "http://rubygems.org"
gemspec

gem "posix-spawn", :platforms => :ruby
gem "redcarpet", :platforms => :ruby
gem "kramdown", :platforms => :jruby
gem "RedCloth"
# using a tag version here because 0.18.3 was not published by the author to encourage users to upgrade.
# however we want to bump up to this version since this has a security patch
gem "commonmarker", git: "https://github.com/gjtorikian/commonmarker.git", tag: "v0.18.3"
gem "rdoc", "~>3.6"
gem "rdoc", "~> 6.7.0"
gem "org-ruby", "= 0.9.9"
gem "creole", "~>0.3.6"
gem "wikicloth", "=0.8.3"
gem "twitter-text", "~> 1.14"
gem "asciidoctor", "~> 2.0.5"
gem "rake"
gem "rexml"
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 5.0.0 - 2024-06-17
* Drop support for Ruby versions < 3
* Bump nokogiri from 1.8.1 to 1.16.5
* Bump nokogiri-diff from 0.2.0 to 0.3.0
* Bump rdoc from 3.6 to 6.7.0
* Update CommandImplementation to better support large files (affecting RST and POD6 rendering)

## 4.0.2 - 2023-10-10
* Add support for .mdx files in markdown

Expand Down
7 changes: 4 additions & 3 deletions github-markup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/github/markup"
s.license = "MIT"

s.required_ruby_version = '>= 3.0.0'

s.files = `git ls-files`.split($\)
s.files += Dir['vendor/**/*']
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_paths = %w[lib]
Expand All @@ -24,7 +25,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'minitest', '~> 5.4', '>= 5.4.3'
s.add_development_dependency 'html-pipeline', '~> 1.0'
s.add_development_dependency 'sanitize', '>= 4.6.3'
s.add_development_dependency 'nokogiri', '~> 1.8.1'
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
s.add_development_dependency 'nokogiri', '~> 1.16.5'
s.add_development_dependency 'nokogiri-diff', '~> 0.3.0'
s.add_development_dependency "github-linguist", ">= 7.1.3"
end
2 changes: 1 addition & 1 deletion lib/github-markup.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GitHub
module Markup
VERSION = '4.0.2'
VERSION = '5.0.0'
Version = VERSION
end
end
36 changes: 8 additions & 28 deletions lib/github/markup/command_implementation.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
begin
require "posix-spawn"
rescue LoadError
require "open3"
end

require "open3"
require "github/markup/implementation"


Expand Down Expand Up @@ -39,28 +34,13 @@ def call_block(rendered, content)
end
end

if defined?(POSIX::Spawn)
def execute(command, target)
spawn = POSIX::Spawn::Child.new(*command, :input => target)
if spawn.status.success?
sanitize(spawn.out, target.encoding)
else
raise CommandError.new(spawn.err.strip)
end
end
else
def execute(command, target)
output = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
stdin.puts target
stdin.close
if wait_thr.value.success?
stdout.readlines
else
raise CommandError.new(stderr.readlines.join('').strip)
end
end
sanitize(output.join(''), target.encoding)
end
def execute(command, target)
# capture3 blocks until both buffers are written to and the process terminates, but
# it won't allow either buffer to fill up
stdout, stderr, status = Open3.capture3(*command, stdin_data: target)

raise CommandError.new(stderr) unless status.success?
sanitize(stdout, target.encoding)
end

def sanitize(input, encoding)
Expand Down
7 changes: 6 additions & 1 deletion test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def call
f.close_write
f.read
end

if ENV['UPDATE']
File.open(expected_file, 'w') { |f| f.write actual }
end

assert_html_equal expected, actual, <<message
#{File.basename expected_file}'s contents are not html equal to output:
#{diff}
Expand Down Expand Up @@ -106,7 +111,7 @@ def test_raises_error_if_command_exits_non_zero
begin
GitHub::Markup.render('README.java', "stop swallowing errors", symlink: false)
rescue GitHub::Markup::CommandError => e
assert_equal "failure message", e.message
assert_equal "failure message", e.message.strip
else
fail "an exception was expected but was not raised"
end
Expand Down
2 changes: 1 addition & 1 deletion test/markups/README.asciidoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ <h2>Another Section</h2>
<p>content</p>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion test/markups/README.hidetitle.asciidoc.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div>
<p>This test verifies the author can disable the document title by adding <code>:!showtitle:</code> to the document header.</p>
</div>
</div>
2 changes: 1 addition & 1 deletion test/markups/README.litcoffee.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ <h2>Literate CoffeeScript Test</h2>
</ul>
<p>Tabs work too:</p>
<p>test "tabbed code", -&gt;
ok yes</p>
ok yes</p>
Loading
Loading