module Prolog::Services::MarkdownToHtml::Renderer::HtmlPipelineConverter::Internals

Support methods, to be hidden from outside view.

Public Class Methods

clean_void_elements(markup) click to toggle source

Void elements supported:

%w(br hr img)

Unsupported void elements:

%w(area base col command embed input keygen link meta param
   source track wbr)

As per www.w3.org/TR/html-markup/syntax.html#void-element

# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 25
def self.clean_void_elements(markup)
  markup.gsub(/<br(.*?)>/, '<br\1/>')
        .gsub(/<hr(.*?)>/, '<hr\1/>')
        .gsub(/<img(.*?)>/, '<img\1/>')
end
cleanup(content) click to toggle source
# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 15
def self.cleanup(content)
  clean_void_elements(strip_lines_in(content).join)
end
context() click to toggle source
# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 35
def self.context
  {
    gfm: true,
    asset_root: '/images', # for emoji
    base_url: 'https://github.com/' # for @mentions
  }
end
filters() click to toggle source
# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 43
def self.filters
  [
    HTML::Pipeline::MarkdownFilter,
    HTML::Pipeline::ImageMaxWidthFilter,
    HTML::Pipeline::MentionFilter,
    HTML::Pipeline::EmojiFilter,
    # HTML::Pipeline::SyntaxHighlightFilter,
    HTML::Pipeline::AutolinkFilter
  ]
end
pipeline() click to toggle source
# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 54
def self.pipeline
  HTML::Pipeline.new filters, context
end
strip_lines_in(content) click to toggle source
# File lib/prolog/services/markdown_to_html/renderer/html_pipeline_converter.rb, line 31
def self.strip_lines_in(content)
  content.lines.map(&:rstrip)
end