Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace rdiscount filter with config-aware markdownify.

  • Loading branch information...
commit 851172b5ef1a7c649296dd00390c067168eebc0f 1 parent cae0eaf
@mojombo mojombo authored
View
1  History.txt
@@ -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
View
12 lib/jekyll/filters.rb
@@ -9,16 +9,20 @@ module Filters
#
# 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".
View
13 lib/jekyll/site.rb
@@ -314,5 +314,18 @@ def filter_entries(entries)
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
View
1  test/helper.rb
@@ -12,7 +12,6 @@
require 'shoulda'
require 'rr'
-
include Jekyll
# Send STDERR into the void to suppress program output messages
View
9 test/test_filters.rb
@@ -3,6 +3,11 @@
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 JekyllFilter
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
Please sign in to comment.
Something went wrong with that request. Please try again.