diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52d4db54..722c3360 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..47725433 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.2 diff --git a/Gemfile b/Gemfile index c98072f2..864416c2 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/HISTORY.md b/HISTORY.md index 57145177..9a2f8744 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/README.md b/README.md index b2bcc809..69a64918 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/github-markup.gemspec b/github-markup.gemspec index 594d3507..e36adfa8 100644 --- a/github-markup.gemspec +++ b/github-markup.gemspec @@ -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 diff --git a/lib/github-markup.rb b/lib/github-markup.rb index 58f9b1c5..646e341c 100644 --- a/lib/github-markup.rb +++ b/lib/github-markup.rb @@ -1,6 +1,6 @@ module GitHub module Markup - VERSION = '4.0.2' + VERSION = '5.0.0' Version = VERSION end end diff --git a/lib/github/markup/markdown.rb b/lib/github/markup/markdown.rb index dcf93229..df4a5d93 100644 --- a/lib/github/markup/markdown.rb +++ b/lib/github/markup/markdown.rb @@ -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) diff --git a/test/markup_test.rb b/test/markup_test.rb index 24e78000..5590690c 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -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 @@ -66,6 +65,7 @@ def call f.close_write f.read end + assert_html_equal expected, actual, <Title').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 @@ -118,16 +117,70 @@ def test_preserve_markup end def test_commonmarker_options - assert_equal "

hello world

\n", GitHub::Markup.render("test.md", "hello world") - assert_equal "

hello world

\n", GitHub::Markup.render("test.md", "hello world", options: {commonmarker_opts: [:UNSAFE]}) - - assert_equal "

hello world

\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello world") - assert_equal "

hello world

\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello world", options: {commonmarker_opts: [:UNSAFE]}) - - assert_equal "<style>.red{color: red;}</style>\n", GitHub::Markup.render("test.md", "", options: {commonmarker_opts: [:UNSAFE]}) - assert_equal "\n", GitHub::Markup.render("test.md", "", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]}) - - assert_equal "<style>.red{color: red;}</style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "", options: {commonmarker_opts: [:UNSAFE]}) - assert_equal "\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]}) + assert_equal( + "

hello world

\n", + GitHub::Markup.render("test.md", "hello world"), + ) + assert_equal( + "

hello world

\n", + GitHub::Markup.render( + "test.md", + "hello world", + options: { commonmarker_opts: [:UNSAFE] }, + ), + ) + + assert_equal( + "

hello world

\n", + GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "hello world"), + ) + assert_equal( + "

hello world

\n", + GitHub::Markup.render_s( + GitHub::Markups::MARKUP_MARKDOWN, + "hello world", + options: { commonmarker_opts: [:UNSAFE] }, + ), + ) + + assert_equal( + "<style>.red{color: red;}</style>\n", + GitHub::Markup.render( + "test.md", + "", + options: { commonmarker_opts: [:UNSAFE] }, + ), + ) + assert_equal( + "\n", + GitHub::Markup.render( + "test.md", + "", + options: { + commonmarker_opts: [:UNSAFE], + commonmarker_exts: [:autolink, :table, :strikethrough], + }, + ), + ) + + assert_equal( + "<style>.red{color: red;}</style>\n", + GitHub::Markup.render_s( + GitHub::Markups::MARKUP_MARKDOWN, + "", + options: { commonmarker_opts: [:UNSAFE] }, + ), + ) + assert_equal( + "\n", + GitHub::Markup.render_s( + GitHub::Markups::MARKUP_MARKDOWN, + "", + options: { + commonmarker_opts: [:UNSAFE], + commonmarker_exts: [:autolink, :table, :strikethrough], + }, + ), + ) end end diff --git a/test/markups/README.asciidoc.html b/test/markups/README.asciidoc.html index 6f478cab..8019074b 100644 --- a/test/markups/README.asciidoc.html +++ b/test/markups/README.asciidoc.html @@ -59,4 +59,4 @@

Another Section

content

- + \ No newline at end of file diff --git a/test/markups/README.hidetitle.asciidoc.html b/test/markups/README.hidetitle.asciidoc.html index ae6b258f..02a55fe7 100644 --- a/test/markups/README.hidetitle.asciidoc.html +++ b/test/markups/README.hidetitle.asciidoc.html @@ -1,3 +1,3 @@

This test verifies the author can disable the document title by adding :!showtitle: to the document header.

-
+ \ No newline at end of file diff --git a/test/markups/README.litcoffee.html b/test/markups/README.litcoffee.html index 51ffe528..c3100567 100644 --- a/test/markups/README.litcoffee.html +++ b/test/markups/README.litcoffee.html @@ -3,37 +3,37 @@

Literate CoffeeScript Test

Taken from https://github.com/jashkenas/coffee-script/blob/master/test/literate.litcoffee

comment comment

-
test "basic literate CoffeeScript parsing", ->
-  ok yes
-
+
test "basic literate CoffeeScript parsing", ->
+  ok yes
+

now with a...

-
test "broken up indentation", ->
-
+
test "broken up indentation", ->
+

... broken up ...

-
  do ->
-
+
  do ->
+

... nested block.

-
    ok yes
-
+
    ok yes
+

Code must be separated from text by a blank line.

-
test "code blocks must be preceded by a blank line", ->
-
+
test "code blocks must be preceded by a blank line", ->
+

The next line is part of the text and will not be executed. fail()

-
  ok yes
-
+
  ok yes
+

Code in backticks is not parsed and...

-
test "comments in indented blocks work", ->
-  do ->
-    do ->
-      # Regular comment.
-
-      ###
-        Block comment.
-      ###
-
-      ok yes
-
+
test "comments in indented blocks work", ->
+  do ->
+    do ->
+      # Regular comment.
+
+      ###
+        Block comment.
+      ###
+
+      ok yes
+

Regular Markdown features, like links and unordered lists, are fine:

    @@ -52,4 +52,4 @@

    Literate CoffeeScript Test

Tabs work too:

test "tabbed code", -> -ok yes

+ok yes

\ No newline at end of file diff --git a/test/markups/README.mediawiki b/test/markups/README.mediawiki deleted file mode 100644 index c3cc004a..00000000 --- a/test/markups/README.mediawiki +++ /dev/null @@ -1,30 +0,0 @@ -[[Home|» JRuby Project Wiki Home Page]] -

Embedding JRuby

-Using Java from Ruby is JRuby's best-known feature---but you can also go in the other direction, and use Ruby from Java. There are several different ways to do this. You can execute entire Ruby scripts, call individual Ruby methods, or even implement a Java interface in Ruby (thus allowing you to treat Ruby objects like Java ones). We refer to all these techniques generically as "embedding." This section will explain how to embed JRuby in your Java project. - -__TOC__ - -= Red Bridge (JRuby Embed) = - -one- -
a-b
- -JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the [[DirectJRubyEmbedding|legacy API]] should still work, but we strongly recommend Red Bridge for all new projects. - -== Features of Red Bridge == -Red Bridge consists of two layers: Embed Core on the bottom, and implementations of [http://www.jcp.org/en/jsr/detail?id=223 JSR223] and [http://jakarta.apache.org/bsf/ BSF] on top. Embed Core is JRuby-specific, and can take advantage of much of JRuby's power. JSR223 and BSF are more general interfaces that provide a common ground across scripting languages. - -Which API should you use? For projects where Ruby is the only scripting language involved, we recommend Embed Core for the following reasons: - -# With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via org.jruby.RubyInstanceConfig. With the other APIs, configuration options can only be set globally, via the System properties. -# Embed Core offers several shortcuts, such as loading scripts from a java.io.InputStream, or returning Java-friendly objects from Ruby code. These allow you to skip a lot of boilerplate. - -For projects requiring multiple scripting languages, JSR223 is a good fit. Though the API is language-independent, JRuby's implementation of it allows you to set some Ruby-specific options. In particular, you can control the threading model of the scripting engine, the lifetime of local variables, compilation mode, and how line numbers are displayed. - -The full [http://jruby-embed.kenai.com/docs/ API documentation] has all the gory details. It's worth talking about a couple of the finer points here. - -= Previous Embedding JRuby Page= -We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the [[JavaIntegration|legacy embedding]]This link goes nowhere. page. - -= References = - diff --git a/test/markups/README.mediawiki.html b/test/markups/README.mediawiki.html deleted file mode 100644 index fcc56bfe..00000000 --- a/test/markups/README.mediawiki.html +++ /dev/null @@ -1,60 +0,0 @@ -

» JRuby Project Wiki Home Page -

Embedding JRuby

-Using Java from Ruby is JRuby's best-known feature---but you can also go in the other direction, and use Ruby from Java. There are several different ways to do this. You can execute entire Ruby scripts, call individual Ruby methods, or even implement a Java interface in Ruby (thus allowing you to treat Ruby objects like Java ones). We refer to all these techniques generically as "embedding." This section will explain how to embed JRuby in your Java project. - -

-

Table of Contents

- -
- - -

-Red Bridge (JRuby Embed)

- - -

one-<two -

a-b
- - -

JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the legacy API should still work, but we strongly recommend Red Bridge for all new projects. -

- -

-Features of Red Bridge

- - -

Red Bridge consists of two layers: Embed Core on the bottom, and implementations of JSR223 and BSF on top. Embed Core is JRuby-specific, and can take advantage of much of JRuby's power. JSR223 and BSF are more general interfaces that provide a common ground across scripting languages. -

-

Which API should you use? For projects where Ruby is the only scripting language involved, we recommend Embed Core for the following reasons: -

- - - -

    -
  1. With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via org.jruby.RubyInstanceConfig. With the other APIs, configuration options can only be set globally, via the System properties.
  2. -
  3. Embed Core offers several shortcuts, such as loading scripts from a java.io.InputStream, or returning Java-friendly objects from Ruby code. These allow you to skip a lot of boilerplate.
  4. -
-For projects requiring multiple scripting languages, JSR223 is a good fit. Though the API is language-independent, JRuby's implementation of it allows you to set some Ruby-specific options. In particular, you can control the threading model of the scripting engine, the lifetime of local variables, compilation mode, and how line numbers are displayed. - -

The full API documentation has all the gory details. It's worth talking about a couple of the finer points here. -

- -

-Previous Embedding JRuby Page

- - -

We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the legacy embedding[1] page. -

- -

-References

- - -

  1. -^ This link goes nowhere.
\ No newline at end of file diff --git a/test/markups/README.org.html b/test/markups/README.org.html index ddf8b27e..e9b2d7ec 100644 --- a/test/markups/README.org.html +++ b/test/markups/README.org.html @@ -13,14 +13,17 @@

org-ruby

0.9.0 -

1 Description

+

+1 Description

Helpful Ruby routines for parsing orgmode files. The most significant thing this library does today is convert orgmode files to textile. Currently, you cannot do much to customize the conversion. The supplied textile conversion is optimized for extracting “content” from the orgfile as opposed to “metadata.”

-

2 History

-

2.1 2014-02-08: Version 0.9.0

+

+2 History

+

+2.1 2014-02-08: Version 0.9.0

  • Let’s make sure #+INCLUDE: is not supported
@@ -35,13 +38,15 @@

2.1 2014-02-08: Version 0.9.0

end end -

2.2 2009-12-30: Version 0.5.1

+

+2.2 2009-12-30: Version 0.5.1

  • Minor enhancement: Recognize lines starting with “:” as examples.
  • Minor enhancement: Recognize #+BEGIN_SRC as source blocks
  • Minor enhancement: Add “src” and “example” classes to <pre> blocks.
-

2.3 2009-12-30: Version 0.5.0

+

+2.3 2009-12-30: Version 0.5.0

  • Parse (but not necessarily use) in-buffer settings. The following in-buffer settings are used: @@ -65,7 +70,8 @@

    2.3 2009-12-30: Version 0.5.0

-

2.4 2009-12-29: Version 0.4.2

+

+2.4 2009-12-29: Version 0.4.2

  • Got rid of the extraneous newline at the start of code blocks.
  • Everything now shows up in code blocks, even org-mode metadata.
  • @@ -76,12 +82,14 @@

    2.4 2009-12-29: Version 0.4.2

-

2.5 2009-12-29: Version 0.4.1

+

+2.5 2009-12-29: Version 0.4.1

  • HTML is now escaped by default
  • org-mode comments will show up in a code block.
-

2.6 2009-12-29: Version 0.4

+

+2.6 2009-12-29: Version 0.4

  • The first thing output in HTML gets the class “title”
  • HTML output is now indented
  • @@ -94,7 +102,8 @@

    2.6 2009-12-29: Version 0.4

-

2.7 2009-12-27: Version 0.3

+

+2.7 2009-12-27: Version 0.3

  • Uses rubypants to get better typography (smart quotes, ellipses, etc…).
  • Fixed bugs: @@ -105,14 +114,16 @@

    2.7 2009-12-27: Version 0.3

-

2.8 2009-12-26: Version 0.2

+

+2.8 2009-12-26: Version 0.2

  • Added to_html output on the parser.
  • Added support for the full range of inline markup: bold, - italic, code, verbatim, underline, strikethrough.
  • + italic, code, verbatim, underline, strikethrough.
  • Lots of refactoring to make the code more maintainable.
-

2.9 2009-12-23: Version 0.1

+

+2.9 2009-12-23: Version 0.1

  • Added support for block code, like this:
    diff --git a/test/markups/README.pod.html b/test/markups/README.pod.html
    index a62c65db..63caf6bc 100644
    --- a/test/markups/README.pod.html
    +++ b/test/markups/README.pod.html
    @@ -10,7 +10,8 @@ 

    ABOUT

      -
    • Create a working compiler that understands the majority of the MATLAB/Octave programming language.

      +
    • +

      Create a working compiler that understands the majority of the MATLAB/Octave programming language.

    @@ -21,13 +22,16 @@

    IMPLEMENTATION

      -
    • The first is the parser, located in the src/parser/ directory. The parser proper is composed of three source files, grammar.pg which is a Perl6Grammar file, and actions.pm which is the associated actions file written in NQP, and grammar-oper.pm which is the operator precedence parser. In addition, several helper functions used by the parser are located in src/internals.

      +
    • +

      The first is the parser, located in the src/parser/ directory. The parser proper is composed of three source files, grammar.pg which is a Perl6Grammar file, and actions.pm which is the associated actions file written in NQP, and grammar-oper.pm which is the operator precedence parser. In addition, several helper functions used by the parser are located in src/internals.

    • -
    • The second component is the library of builtin functions in the src/builtins/ directory. These functions are, currently, written primarily in PIR. Function names prefixed with an underscore are "private" functions for use with the parser. Other functions should have names which are the same as names for regular MATLAB or Octave functions, since they will be available to the HLL. These are also separated into different namespaces depending on visibility and utility.

      +
    • +

      The second component is the library of builtin functions in the src/builtins/ directory. These functions are, currently, written primarily in PIR. Function names prefixed with an underscore are "private" functions for use with the parser. Other functions should have names which are the same as names for regular MATLAB or Octave functions, since they will be available to the HLL. These are also separated into different namespaces depending on visibility and utility.

    • -
    • A number of library functions are written in M, or mostly M with some inline PIR code in toolbox/.

      +
    • +

      A number of library functions are written in M, or mostly M with some inline PIR code in toolbox/.

    diff --git a/test/markups/README.rst.html b/test/markups/README.rst.html index 6accfdf6..f1e6d085 100644 --- a/test/markups/README.rst.html +++ b/test/markups/README.rst.html @@ -2,7 +2,7 @@

    Header 1

    Subtitle

    Example text.

    -

    Table of Contents

    +

    Table of Contents

    • Header 2
    • Field list
    • @@ -17,7 +17,7 @@

      Header 2

      The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.

      -Things that are Awesome (on a scale of 1-11) + @@ -102,7 +102,8 @@

      Header 2

      Things that are Awesome (on a scale of 1-11)
      -Coverity Scan Build Status + +Coverity Scan Build Status Coverity Scan Build Status @@ -133,5 +134,4 @@

      Field list

      someone@somewhere.org

      Press Ctrl+C to quit

      - -

      RAW HTML!

      p {color:blue;} \ No newline at end of file +

      RAW HTML!

      p {color:blue;} \ No newline at end of file diff --git a/test/markups/README.toc.asciidoc.html b/test/markups/README.toc.asciidoc.html index e6f598cf..4e32869a 100644 --- a/test/markups/README.toc.asciidoc.html +++ b/test/markups/README.toc.asciidoc.html @@ -43,4 +43,4 @@

      Subsection B-2

    - + \ No newline at end of file diff --git a/test/markups/README.toc.rst.html b/test/markups/README.toc.rst.html index 4890e99b..c5b3ecbb 100644 --- a/test/markups/README.toc.rst.html +++ b/test/markups/README.toc.rst.html @@ -1,5 +1,5 @@
    -

    Contents

    +

    Contents

    • 1   Introduction
        @@ -29,4 +29,4 @@

        1.2   What is it good for?

      pycparser is unique in the sense that it's written in pure Python - a very high level language that's easy to experiment with and tweak. To people familiar -with Lex and Yacc, pycparser's code will be simple to understand.

      +with Lex and Yacc, pycparser's code will be simple to understand.

      \ No newline at end of file