Class: Jekyll::Converters::Markdown::Hookdown

Inherits:
KramdownParser
  • Object
show all
Defined in:
lib/jekyll-is/hookdown/converter.rb

Instance Method Summary collapse

Instance Method Details

#convert(content) ⇒ String

Parameters:

  • content (String)

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll-is/hookdown/converter.rb', line 12

def convert content
  document = Kramdown::JekyllDocument.new content, @config
  page = JekyllIS::Hookdown::current_page
  case page
  when Jekyll::Page
    Jekyll::Hooks::trigger :pages, :post_parse, page, document
  when Jekyll::Document
    Jekyll::Hooks::trigger :documents, :post_parse, page, document
    if page.respond_to?(:collection) && page.collection&.label == 'posts'
      Jekyll::Hooks::trigger :posts, :post_parse, page, document
    end
  else
    Jekyll::logger.warn JekyllIS::Hookdown::Info::NAME, "Unknown page type: #{ page.inspect }"
  end
  html_output = document.to_html
  if @config['show_warnings']
    document.warnings.each do |warning|
      Jekyll::logger.warn 'Kramdown warning:', warning
    end
  end
  html_output
end