Sha256: 09142b75efcc029654476372a7ae892469f49de9a10e966bd97d65f61a39501e

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

module Jekyll
  module Converters
    class Markdown
      class RDiscountParser
        def initialize(config)
          require 'rdiscount'
          @config = config
          @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'
          raise FatalException.new("Missing dependency: rdiscount")
        end

        def convert(content)
          rd = RDiscount.new(content, *@rdiscount_extensions)
          html = rd.to_html
          if rd.generate_toc and html.include?(@config['rdiscount']['toc_token'])
            html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content.force_encoding('utf-8'))
          end
          html
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-1.0.0 lib/jekyll/converters/markdown/rdiscount_parser.rb
jekyll-1.0.0.rc1 lib/jekyll/converters/markdown/rdiscount_parser.rb