Remove support for rdiscount (#6988)

Merge pull request 6988
This commit is contained in:
jekyllbot 2018-05-09 09:44:36 -04:00 committed by GitHub
parent c2211eec0c
commit 149d5de59a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 4 additions and 129 deletions

View File

@ -76,7 +76,6 @@ group :jekyll_optional_dependencies do
gem "classifier-reborn", "~> 2.2.0"
gem "liquid-c", "~> 3.0"
gem "pygments.rb", "~> 1.0"
gem "rdiscount", "~> 2.0"
gem "yajl-ruby", "~> 1.3"
end

View File

@ -65,14 +65,6 @@ Feature: Site configuration
And the "_site/Rakefile" file should not exist
And the "_site/README" file should not exist
Scenario: Use RDiscount 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 "rdiscount"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "<a href=\"https://www.google.com\">Google</a>" in "_site/index.html"
Scenario: Use Kramdown 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 "kramdown"

View File

@ -66,10 +66,6 @@ module Jekyll
"strict_variables" => false,
},
"rdiscount" => {
"extensions" => [],
},
"kramdown" => {
"auto_ids" => true,
"toc_levels" => "1..6",

View File

@ -30,8 +30,7 @@ module Jekyll
# rubocop:disable Naming/AccessorMethodName
def get_processor
case @config["markdown"].downcase
when "kramdown" then return KramdownParser.new(@config)
when "rdiscount" then return RDiscountParser.new(@config)
when "kramdown" then return KramdownParser.new(@config)
else
custom_processor
end
@ -43,7 +42,7 @@ module Jekyll
# are not in safe mode.)
def valid_processors
%w(rdiscount kramdown) + third_party_processors
%w(kramdown) + third_party_processors
end
# Public: A list of processors that you provide via plugins.
@ -52,7 +51,7 @@ module Jekyll
def third_party_processors
self.class.constants - \
%w(KramdownParser RDiscountParser PRIORITIES).map(
%w(KramdownParser PRIORITIES).map(
&:to_sym
)
end

View File

@ -1,37 +0,0 @@
# frozen_string_literal: true
module Jekyll
module Converters
class Markdown
class RDiscountParser
def initialize(config)
unless defined?(RDiscount)
Jekyll::External.require_with_graceful_fail "rdiscount"
end
@config = config
@rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
end
def convert(content)
rd = RDiscount.new(content, *@rdiscount_extensions)
html = rd.to_html
if @config["rdiscount"]["toc_token"]
html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"])
end
html
end
private
def replace_generated_toc(rd_instance, html, toc_token)
if rd_instance.generate_toc && html.include?(toc_token)
utf8_toc = rd_instance.toc_content
utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding)
html.gsub(toc_token, utf8_toc)
else
html
end
end
end
end
end
end

View File

@ -34,10 +34,6 @@ require_relative "../lib/jekyll.rb"
Jekyll.logger = Logger.new(StringIO.new, :error)
unless jruby?
require "rdiscount"
end
require "kramdown"
require "shoulda"

View File

@ -1,51 +0,0 @@
# frozen_string_literal: true
require "helper"
class TestRdiscount < JekyllUnitTest
context "rdiscount" do
setup do
if jruby?
then skip(
"JRuby does not perform well with CExt, test disabled."
)
end
config = {
"markdown" => "rdiscount",
"rdiscount" => {
"toc_token" => "{:toc}",
"extensions" => %w(smart generate_toc),
},
}
@markdown = Converters::Markdown.new config
end
should "pass rdiscount extensions" do
assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
end
should "render toc" do
toc = <<-TOC
<a name="Header.1"></a>
<h1>Header 1</h1>
<a name="Header.2"></a>
<h2>Header 2</h2>
<p><ul>
<li><a href="#Header.1">Header 1</a>
<ul>
<li><a href="#Header.2">Header 2</a></li>
</ul>
</li>
</ul>
</p>
TOC
assert_equal toc.strip,
@markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip
end
end
end

View File

@ -494,7 +494,7 @@ EOS
setup do
@content = <<CONTENT
---
title: Kramdown vs. RDiscount
title: Kramdown post with pre
---
_FIGHT!_
@ -507,25 +507,6 @@ puts "3..2..1.."
CONTENT
end
context "using RDiscount" do
setup do
if jruby?
then skip(
"JRuby does not perform well with CExt, test disabled."
)
end
create_post(@content, {
"markdown" => "rdiscount",
})
end
should "parse correctly" do
assert_match %r{<em>FIGHT!</em>}, @result
assert_match %r!<em>FINISH HIM</em>!, @result
end
end
context "using Kramdown" do
setup do
create_post(@content, "markdown" => "kramdown")