Sha256: 1807794f760dc0adc6980f9b1ad4dc31cc9636b0ab8983b677db1d54d6a156cf

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsduck-4.0.beta2 lib/jsduck/markdown.rb