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 gems and drop support for Ruby versions < 3.1 #1810

Closed
wants to merge 25 commits into from
Closed
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ jobs:
strategy:
matrix:
ruby:
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.1"
- "3.2"
- "3.3"
fail-fast: false

steps:
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.2
13 changes: 6 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ 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 "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 "commonmarker", git: "https://github.com/gjtorikian/commonmarker.git", tag: "v1.1.4"
gem "rdoc", "~> 6.7.0"
gem "org-ruby", "= 0.9.12"
gem "creole", "~> 0.5.0"
gem "rexml"
gem "asciidoctor", "~> 2.0.23"
gem "rake"
11 changes: 11 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 5.0.0 - 2024-06-11
* Drop support for Ruby versions < 3.1.0

* activesupport to 7.1.3.4
* minitest to 5.23.1
* nokogiri to 1.16.5
* nokogiri-diff to 0.3.0
* github-linguist to 7.30.0
* sanitize to 6.1.0
* html-pipeline to 2.14.3

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

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
* [.org](http://orgmode.org/) -- `gem install org-ruby` (https://github.com/wallyqs/org-ruby)
* [.creole](http://wikicreole.org/) -- `gem install creole` (https://github.com/larsch/creole)
* [.mediawiki, .wiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` (https://github.com/nricciar/wikicloth)
- Note: The currently released version of `wikicloth`, `0.8.3`, is not
compatible with the latest version of this gem.
* [.rst](http://docutils.sourceforge.net/rst.html) -- `pip install docutils`
* [.asciidoc, .adoc, .asc](http://asciidoc.org/) -- `gem install asciidoctor` (http://asciidoctor.org)
* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::XHTML`
Expand Down
18 changes: 9 additions & 9 deletions github-markup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ Gem::Specification.new do |s|
s.license = "MIT"

s.files = `git ls-files`.split($\)
s.files += Dir['vendor/**/*']
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]

s.add_development_dependency 'rake', '~> 12'
s.add_development_dependency 'activesupport', '~> 4.0'
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 "github-linguist", ">= 7.1.3"
s.add_development_dependency "rake", "~> 12"
s.add_development_dependency "activesupport", "~> 7.1.3.4"
s.add_development_dependency "minitest", "~> 5.23.1"
s.add_development_dependency "html-pipeline", "~> 2.14.3"
s.add_development_dependency "sanitize", "~> 6.1.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.30.0"
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
8 changes: 7 additions & 1 deletion lib/github/markup/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ class Markdown < Implementation
"commonmarker" => proc { |content, options: {}|
commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
commonmarker_exts = options.fetch(:commonmarker_exts, [:tagfilter, :autolink, :table, :strikethrough])
CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts)
Commonmarker.to_html(
content,
options: {
render: commonmarker_opts.map { |opt| [opt.downcase, true] }.to_h,
extension: commonmarker_exts.map { |ext| [ext.downcase, true] }.to_h,
},
)
},
"github/markdown" => proc { |content, options: {}|
GitHub::Markdown.render(content)
Expand Down
79 changes: 66 additions & 13 deletions test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def call
markup = readme.split('/').last.gsub(/^README\./, '')

define_method "test_#{markup}" do
skip "Skipping MediaWiki test because wikicloth is currently not compatible with JRuby." if markup == "mediawiki" && RUBY_PLATFORM == "java"
source = File.read(readme)
expected_file = "#{readme}.html"
expected = File.read(expected_file).rstrip
Expand All @@ -66,6 +65,7 @@ def call
f.close_write
f.read
end

assert_html_equal expected, actual, <<message
#{File.basename expected_file}'s contents are not html equal to output:
#{diff}
Expand All @@ -86,7 +86,6 @@ def test_each_render_has_a_name
assert_equal "rdoc", GitHub::Markup.renderer('README.rdoc', '* One').name
assert_equal "org-ruby", GitHub::Markup.renderer('README.org', '* Title').name
assert_equal "creole", GitHub::Markup.renderer('README.creole', '= Title =').name
assert_equal "wikicloth", GitHub::Markup.renderer('README.wiki', '<h1>Title</h1>').name
assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name
assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name
assert_equal "pod", GitHub::Markup.renderer('README.pod', '=head1').name
Expand Down Expand Up @@ -118,16 +117,70 @@ def test_preserve_markup
end

def test_commonmarker_options
assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world")
assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render("test.md", "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})

assert_equal "<p>hello <!-- raw HTML omitted --> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world")
assert_equal "<p>hello <bad> world</p>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world", options: {commonmarker_opts: [:UNSAFE]})

assert_equal "&lt;style>.red{color: red;}&lt;/style>\n", GitHub::Markup.render("test.md", "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE]})
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]})

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]})
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]})
assert_equal(
"<p>hello <!-- raw HTML omitted --> world</p>\n",
GitHub::Markup.render("test.md", "hello <bad> world"),
)
assert_equal(
"<p>hello <bad> world</p>\n",
GitHub::Markup.render(
"test.md",
"hello <bad> world",
options: { commonmarker_opts: [:UNSAFE] },
),
)

assert_equal(
"<p>hello <!-- raw HTML omitted --> world</p>\n",
GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello <bad> world"),
)
assert_equal(
"<p>hello <bad> world</p>\n",
GitHub::Markup.render_s(
GitHub::Markups::MARKUP_MARKDOWN,
"hello <bad> world",
options: { commonmarker_opts: [:UNSAFE] },
),
)

assert_equal(
"&lt;style>.red{color: red;}&lt;/style>\n",
GitHub::Markup.render(
"test.md",
"<style>.red{color: red;}</style>",
options: { commonmarker_opts: [:UNSAFE] },
),
)
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],
},
),
)

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] },
),
)
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],
},
),
)
end
end
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>
50 changes: 25 additions & 25 deletions test/markups/README.litcoffee.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ <h2>Literate CoffeeScript Test</h2>
<p>Taken from <a href="https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee">https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee</a></p>
</blockquote>
<p>comment comment</p>
<pre><code>test "basic literate CoffeeScript parsing", -&gt;
ok yes
</code></pre>
<pre><code><span>test "basic literate CoffeeScript parsing", -&gt;
</span><span> ok yes
</span></code></pre>
<p>now with a...</p>
<pre><code>test "broken up indentation", -&gt;
</code></pre>
<pre><code><span>test "broken up indentation", -&gt;
</span></code></pre>
<p>... broken up ...</p>
<pre><code> do -&gt;
</code></pre>
<pre><code><span> do -&gt;
</span></code></pre>
<p>... nested block.</p>
<pre><code> ok yes
</code></pre>
<pre><code><span> ok yes
</span></code></pre>
<p>Code must be separated from text by a blank line.</p>
<pre><code>test "code blocks must be preceded by a blank line", -&gt;
</code></pre>
<pre><code><span>test "code blocks must be preceded by a blank line", -&gt;
</span></code></pre>
<p>The next line is part of the text and will not be executed.
fail()</p>
<pre><code> ok yes
</code></pre>
<pre><code><span> ok yes
</span></code></pre>
<p>Code in <code>backticks is not parsed</code> and...</p>
<pre><code>test "comments in indented blocks work", -&gt;
do -&gt;
do -&gt;
# Regular comment.

###
Block comment.
###

ok yes
</code></pre>
<pre><code><span>test "comments in indented blocks work", -&gt;
</span><span> do -&gt;
</span><span> do -&gt;
</span><span> # Regular comment.
</span><span>
</span><span> ###
</span><span> Block comment.
</span><span> ###
</span><span>
</span><span> ok yes
</span></code></pre>
<p>Regular <a href="http://example.com/markdown">Markdown</a> features,
like links and unordered lists, are fine:</p>
<ul>
Expand All @@ -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>
30 changes: 0 additions & 30 deletions test/markups/README.mediawiki

This file was deleted.

60 changes: 0 additions & 60 deletions test/markups/README.mediawiki.html

This file was deleted.

Loading
Loading