Module: Webgen::ContentProcessor::Kramdown

Defined in:
lib/webgen/content_processor/kramdown.rb

Overview

Processes content in kramdown format (based on Markdown) using the kramdown library.

Defined Under Namespace

Classes: CustomHtmlConverter

Class Method Summary collapse

Class Method Details

.call(context) ⇒ Object

Convert the content in context to HTML.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/webgen/content_processor/kramdown.rb', line 51

def self.call(context)
  options = context.website.config['content_processor.kramdown.options'].dup
  options[:link_defs] = context.website.ext.link_definitions.merge(options[:link_defs] || {})
  options[:input] = 'WebgenKramdown'
  doc = ::Kramdown::Document.new(context.content, options)
  context.content = CustomHtmlConverter.new(doc.root, doc.options, context).convert(doc.root)
  context.content.encode!(doc.root.options[:encoding])
  doc.warnings.each do |warn|
    context.website.logger.warn { "kramdown warning while parsing <#{context.ref_node}>: #{warn}" }
  end
  context
end