diff --git a/Gemfile b/Gemfile index 88a4e5bd..1f31549e 100644 --- a/Gemfile +++ b/Gemfile @@ -77,7 +77,6 @@ group :jekyll_optional_dependencies do gem "liquid-c", "~> 3.0" gem "pygments.rb", "~> 1.0" gem "rdiscount", "~> 2.0" - gem "redcarpet", "~> 3.2", ">= 3.2.3" gem "yajl-ruby", "~> 1.3" end diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 6dc6f5b0..4baa36a8 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -81,14 +81,6 @@ Feature: Site configuration And the _site directory should exist And I should see "Google" in "_site/index.html" - Scenario: Use Redcarpet for markup - Given I have an "index.markdown" page that contains "[Google](https://www.google.com)" - And I have a configuration file with "markdown" set to "redcarpet" - When I run jekyll build - Then I should get a zero exit status - And the _site directory should exist - And I should see "Google" in "_site/index.html" - Scenario: Highlight code with pygments Given I have an "index.html" page that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}" When I run jekyll build diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index f64264c9..fb51cd5b 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -70,10 +70,6 @@ module Jekyll "extensions" => [], }, - "redcarpet" => { - "extensions" => [], - }, - "kramdown" => { "auto_ids" => true, "toc_levels" => "1..6", diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 17d102ff..567bc120 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -30,7 +30,6 @@ module Jekyll # rubocop:disable Naming/AccessorMethodName def get_processor case @config["markdown"].downcase - when "redcarpet" then return RedcarpetParser.new(@config) when "kramdown" then return KramdownParser.new(@config) when "rdiscount" then return RDiscountParser.new(@config) else @@ -44,7 +43,7 @@ module Jekyll # are not in safe mode.) def valid_processors - %w(rdiscount kramdown redcarpet) + third_party_processors + %w(rdiscount kramdown) + third_party_processors end # Public: A list of processors that you provide via plugins. @@ -53,7 +52,7 @@ module Jekyll def third_party_processors self.class.constants - \ - %w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map( + %w(KramdownParser RDiscountParser PRIORITIES).map( &:to_sym ) end diff --git a/lib/jekyll/converters/markdown/redcarpet_parser.rb b/lib/jekyll/converters/markdown/redcarpet_parser.rb deleted file mode 100644 index d9383b7b..00000000 --- a/lib/jekyll/converters/markdown/redcarpet_parser.rb +++ /dev/null @@ -1,113 +0,0 @@ -# frozen_string_literal: true - -class Jekyll::Converters::Markdown::RedcarpetParser - module CommonMethods - def add_code_tags(code, lang) - code = code.to_s - code = code.sub( - %r!
!,
-        "
"
-      )
-      code = code.sub(%r!
!, "
") - code - end - end - - module WithPygments - include CommonMethods - def block_code(code, lang) - unless defined?(Pygments) - Jekyll::External.require_with_graceful_fail("pygments") - end - lang = lang && lang.split.first || "text" - add_code_tags( - Pygments.highlight( - code, - { - :lexer => lang, - :options => { :encoding => "utf-8" }, - } - ), - lang - ) - end - end - - module WithoutHighlighting - require "cgi" - - include CommonMethods - - def code_wrap(code) - "
#{CGI.escapeHTML(code)}
" - end - - def block_code(code, lang) - lang = lang && lang.split.first || "text" - add_code_tags(code_wrap(code), lang) - end - end - - module WithRouge - def block_code(_code, lang) - code = "
#{super}
" - - "
#{add_code_tags(code, lang)}
" - end - - protected - def rouge_formatter(_lexer) - require "rouge" - ::Rouge::Formatters::HTMLLegacy.new(:wrap => false) - end - end - - def initialize(config) - unless defined?(Redcarpet) - Jekyll::External.require_with_graceful_fail("redcarpet") - end - @config = config - @redcarpet_extensions = {} - @config["redcarpet"]["extensions"].each do |e| - @redcarpet_extensions[e.to_sym] = true - end - - @renderer ||= class_with_proper_highlighter(@config["highlighter"]) - end - - def class_with_proper_highlighter(highlighter) - Class.new(Redcarpet::Render::HTML) do - case highlighter - when "pygments" - include WithPygments - when "rouge" - Jekyll::External.require_with_graceful_fail(%w( - rouge rouge/plugins/redcarpet - )) - - unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0") - abort "Please install Rouge 1.3.0 or greater and try running Jekyll again." - end - - include Rouge::Plugins::Redcarpet - include CommonMethods - include WithRouge - else - include WithoutHighlighting - end - end - end - - def convert(content) - @redcarpet_extensions[:fenced_code_blocks] = \ - !@redcarpet_extensions[:no_fenced_code_blocks] - if @redcarpet_extensions[:smart] - @renderer.send :include, Redcarpet::Render::SmartyPants - end - markdown = Redcarpet::Markdown.new( - @renderer.new(@redcarpet_extensions), - @redcarpet_extensions - ) - markdown.render(content) - end -end diff --git a/test/helper.rb b/test/helper.rb index aa94be13..a3cd6568 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -36,7 +36,6 @@ Jekyll.logger = Logger.new(StringIO.new, :error) unless jruby? require "rdiscount" - require "redcarpet" end require "kramdown" diff --git a/test/test_redcarpet.rb b/test/test_redcarpet.rb deleted file mode 100644 index 51da49c5..00000000 --- a/test/test_redcarpet.rb +++ /dev/null @@ -1,94 +0,0 @@ -# frozen_string_literal: true - -require "helper" - -class TestRedcarpet < JekyllUnitTest - context "redcarpet" do - setup do - if jruby? - then skip( - "JRuby does not perform well with CExt, test disabled." - ) - end - - @config = { - "markdown" => "redcarpet", - "redcarpet" => { - "extensions" => %w(smart strikethrough filter_html), - }, - } - - @markdown = Converters::Markdown.new @config - - @sample = Jekyll::Utils.strip_heredoc(<<-EOS - ```ruby - puts "Hello world" - ``` - EOS - ) - end - - should "pass redcarpet options" do - assert_equal "

Some Header

", @markdown.convert("# Some Header #").strip - end - - should "pass redcarpet SmartyPants options" do - assert_equal "

“smart”

", @markdown.convert('"smart"').strip - end - - should "pass redcarpet extensions" do - assert_equal "

deleted

", @markdown.convert("~~deleted~~").strip - end - - should "pass redcarpet render options" do - assert_equal "

bad code not here: i am bad

", - @markdown.convert("**bad code not here**: ").strip - end - - context "with pygments enabled" do - setup do - @markdown = Converters::Markdown.new @config.merge( - { "highlighter" => "pygments" } - ) - end - - should "render fenced code blocks with syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - - context "with rouge enabled" do - setup do - @markdown = Converters::Markdown.new @config.merge({ "highlighter" => "rouge" }) - end - - should "render fenced code blocks with syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - - context "without any highlighter" do - setup do - @markdown = Converters::Markdown.new @config.merge({ "highlighter" => nil }) - end - - should "render fenced code blocks without syntax highlighting" do - assert_equal( - %(
puts "Hello world"\n
), - @markdown.convert(@sample).strip - ) - end - end - end -end diff --git a/test/test_tags.rb b/test/test_tags.rb index ee01a596..739ced21 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -494,7 +494,7 @@ EOS setup do @content = <FINISH HIM!, @result end end - - context "using Redcarpet" do - setup do - if jruby? - skip( - "JRuby does not perform well with CExt, test disabled." - ) - end - - create_post(@content, { - "markdown" => "redcarpet", - }) - end - - should "parse correctly" do - assert_match %r{FIGHT!}, @result - assert_match %r!FINISH HIM!, @result - end - end end context "simple page with post linking" do