Replace rdiscount filter with config-aware markdownify.
This commit is contained in:
parent
cae0eaf19c
commit
851172b5ef
|
@ -3,6 +3,7 @@
|
||||||
* Add command line importer functionality (#253)
|
* Add command line importer functionality (#253)
|
||||||
* Add Recarpet Markdown support (#318)
|
* Add Recarpet Markdown support (#318)
|
||||||
* Make markdown/textile extensions configurable (#312)
|
* Make markdown/textile extensions configurable (#312)
|
||||||
|
* Add `markdownify` filter
|
||||||
* Minor Enhancements
|
* Minor Enhancements
|
||||||
* Switch to Albino gem
|
* Switch to Albino gem
|
||||||
* Bundler support
|
* Bundler support
|
||||||
|
|
|
@ -9,16 +9,20 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the HTML formatted String.
|
# Returns the HTML formatted String.
|
||||||
def textilize(input)
|
def textilize(input)
|
||||||
TextileConverter.new.convert(input)
|
site = @context.registers[:site]
|
||||||
|
converter = site.getConverterImpl(Jekyll::TextileConverter)
|
||||||
|
converter.convert(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a Markdown string into HTML output using RDiscount.
|
# Convert a Markdown string into HTML output.
|
||||||
#
|
#
|
||||||
# input - The Markdown String to convert.
|
# input - The Markdown String to convert.
|
||||||
#
|
#
|
||||||
# Returns the HTML formatted String.
|
# Returns the HTML formatted String.
|
||||||
def rdiscount(input)
|
def markdownify(input)
|
||||||
RDiscount.new(input).to_html
|
site = @context.registers[:site]
|
||||||
|
converter = site.getConverterImpl(Jekyll::MarkdownConverter)
|
||||||
|
converter.convert(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format a date in short format e.g. "27 Jan 2011".
|
# Format a date in short format e.g. "27 Jan 2011".
|
||||||
|
|
|
@ -314,5 +314,18 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get the implementation class for the given Converter.
|
||||||
|
#
|
||||||
|
# klass - The Class of the Converter to fetch.
|
||||||
|
#
|
||||||
|
# Returns the Converter instance implementing the given Converter.
|
||||||
|
def getConverterImpl(klass)
|
||||||
|
matches = self.converters.select { |c| c.class == klass }
|
||||||
|
if impl = matches.first
|
||||||
|
impl
|
||||||
|
else
|
||||||
|
raise "Converter implementation not found for #{klass}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,6 @@ require 'redgreen' if RUBY_VERSION < '1.9'
|
||||||
require 'shoulda'
|
require 'shoulda'
|
||||||
require 'rr'
|
require 'rr'
|
||||||
|
|
||||||
|
|
||||||
include Jekyll
|
include Jekyll
|
||||||
|
|
||||||
# Send STDERR into the void to suppress program output messages
|
# Send STDERR into the void to suppress program output messages
|
||||||
|
|
|
@ -3,6 +3,11 @@ require 'helper'
|
||||||
class TestFilters < Test::Unit::TestCase
|
class TestFilters < Test::Unit::TestCase
|
||||||
class JekyllFilter
|
class JekyllFilter
|
||||||
include Jekyll::Filters
|
include Jekyll::Filters
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
site = Jekyll::Site.new(Jekyll.configuration({}))
|
||||||
|
@context = Liquid::Context.new({}, {}, { :site => site })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "filters" do
|
context "filters" do
|
||||||
|
@ -14,8 +19,8 @@ class TestFilters < Test::Unit::TestCase
|
||||||
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "rdiscount with simple string" do
|
should "markdownify with simple string" do
|
||||||
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.rdiscount("something **really** simple")
|
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.markdownify("something **really** simple")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "convert array to sentence string with no args" do
|
should "convert array to sentence string with no args" do
|
||||||
|
|
Loading…
Reference in New Issue