Commit 9cbed66d authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Switch back to using RDiscount as only Markdown engine.

As I'm dropping JRuby support, there's no need for extra redirection
layer.
parent 5754ff50
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
require 'rubygems'
require 'strscan'
require 'jsduck/markdown'
require 'rdiscount'
require 'jsduck/logger'
require 'jsduck/inline_img'
require 'jsduck/inline_video'
@@ -310,7 +310,7 @@ module JsDuck
      # code-blocks beginning with empty line.
      input.gsub!(/<pre>(<code>)?\n?/, "<pre>\\1")

      replace(JsDuck::Markdown.to_html(input))
      replace(RDiscount.new(input).to_html)
    end

    # Shortens text

lib/jsduck/markdown.rb

deleted100644 → 0
+0 −46
Original line number Diff line number Diff line

module JsDuck

  # Wrapper which chooses the available Markdown implementation and
  # provides a uniform interface to it.
  #
  # Possible engines in order of preference:
  #
  # - rdiscount
  # - kramdown
  #
  class Markdown

    if RUBY_PLATFORM == "java"
      require "kramdown"
      begin
        @@engine = :kramdown
      rescue LoadError
        throw "ERROR: Kramdown gem not available."
      end
    else
      begin
        require "rdiscount"
        @@engine = :rdiscount
      rescue LoadError
        begin
          require "kramdown"
          @@engine = :kramdown
        rescue LoadError
          throw "ERROR: Neither RDiscount nor Kramdown gem available."
        end
      end
    end

    # Converts Markdown text into HTML
    def self.to_html(input)
      if @@engine == :rdiscount
        RDiscount.new(input).to_html
      else
        Kramdown::Document.new(input).to_html
      end
    end

  end

end