Sha256: 24c5f18728b6031168639840d11cd118ec1d2279b05a7d59d5387b95407c9955

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

# -*- encoding: utf-8 -*-

module Webgen::ContentProcessor

  # Processes content in kramdown format (based on Markdown) using the +kramdown+ library.
  class Kramdown

    include Webgen::Loggable

    # Convert the content in +context+ to HTML.
    def call(context)
      require 'kramdown'
      require 'webgen/contentprocessor/kramdown/html'
      doc = ::Kramdown::Document.new(context.content,
                                     context.website.config['contentprocessor.kramdown.options'].merge(context.options['contentprocessor.kramdown.options'] || {}))
      context.content = KramdownHtmlConverter.convert(doc.root, doc.options, context)
      doc.warnings.each do |warn|
        log(:warn) { "Warning while parsing <#{context.ref_node}> with kramdown: #{warn}" }
      end
      context
    rescue LoadError
      raise Webgen::LoadError.new('kramdown', self.class.name, context.dest_node, 'kramdown')
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webgen-0.5.17 lib/webgen/contentprocessor/kramdown.rb
webgen-0.5.15 lib/webgen/contentprocessor/kramdown.rb