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 Recarpet Markdown support (#318)
|
||||
* Make markdown/textile extensions configurable (#312)
|
||||
* Add `markdownify` filter
|
||||
* Minor Enhancements
|
||||
* Switch to Albino gem
|
||||
* Bundler support
|
||||
|
|
|
@ -9,16 +9,20 @@ module Jekyll
|
|||
#
|
||||
# Returns the HTML formatted String.
|
||||
def textilize(input)
|
||||
TextileConverter.new.convert(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::TextileConverter)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
# Convert a Markdown string into HTML output using RDiscount.
|
||||
# Convert a Markdown string into HTML output.
|
||||
#
|
||||
# input - The Markdown String to convert.
|
||||
#
|
||||
# Returns the HTML formatted String.
|
||||
def rdiscount(input)
|
||||
RDiscount.new(input).to_html
|
||||
def markdownify(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.getConverterImpl(Jekyll::MarkdownConverter)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
# Format a date in short format e.g. "27 Jan 2011".
|
||||
|
|
|
@ -314,5 +314,18 @@ module Jekyll
|
|||
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
|
||||
|
|
|
@ -12,7 +12,6 @@ require 'redgreen' if RUBY_VERSION < '1.9'
|
|||
require 'shoulda'
|
||||
require 'rr'
|
||||
|
||||
|
||||
include Jekyll
|
||||
|
||||
# Send STDERR into the void to suppress program output messages
|
||||
|
|
|
@ -3,6 +3,11 @@ require 'helper'
|
|||
class TestFilters < Test::Unit::TestCase
|
||||
class JekyllFilter
|
||||
include Jekyll::Filters
|
||||
|
||||
def initialize
|
||||
site = Jekyll::Site.new(Jekyll.configuration({}))
|
||||
@context = Liquid::Context.new({}, {}, { :site => site })
|
||||
end
|
||||
end
|
||||
|
||||
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")
|
||||
end
|
||||
|
||||
should "rdiscount with simple string" do
|
||||
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.rdiscount("something **really** simple")
|
||||
should "markdownify with simple string" do
|
||||
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.markdownify("something **really** simple")
|
||||
end
|
||||
|
||||
should "convert array to sentence string with no args" do
|
||||
|
|
Loading…
Reference in New Issue