Navigation Menu

Skip to content

Commit

Permalink
Add support for rdiscount extensions
Browse files Browse the repository at this point in the history
Specify extensions at your _config.yml file:

    ...
    rdiscount:
        extensions: [smart, autolink]

Available extensions can be found here:
http://rdoc.info/projects/rtomayko/rdiscount

closes jekyll#173
  • Loading branch information
ctrochalakis committed Jun 25, 2010
1 parent 4401566 commit a56eeb8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/jekyll.rb
Expand Up @@ -71,6 +71,9 @@ module Jekyll
'png_engine' => 'blahtex',
'png_dir' => 'images/latex',
'png_url' => '/images/latex'
},
'rdiscount' => {
'extensions' => []
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/jekyll/converters/markdown.rb
Expand Up @@ -13,6 +13,9 @@ def setup
when 'rdiscount'
begin
require 'rdiscount'

# Load rdiscount extensions
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
rescue LoadError
STDERR.puts 'You are missing a library required for Markdown. Please run:'
STDERR.puts ' $ [sudo] gem install rdiscount'
Expand Down Expand Up @@ -67,7 +70,7 @@ def convert(content)
setup
case @config['markdown']
when 'rdiscount'
RDiscount.new(content).to_html
RDiscount.new(content, *@rdiscount_extensions).to_html
when 'maruku'
Maruku.new(content).to_html
end
Expand Down
18 changes: 18 additions & 0 deletions test/test_rdiscount.rb
@@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/helper'

class TestRdiscount < Test::Unit::TestCase

context "rdiscount" do
setup do
config = {
'rdiscount' => { 'extensions' => ['smart'] },
'markdown' => 'rdiscount'
}
@markdown = MarkdownConverter.new config
end

should "pass rdiscount extensions" do
assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
end
end
end

0 comments on commit a56eeb8

Please sign in to comment.