class DocRenderer::Base

This is a basic renderer for transforming markdown to HTML inherit from this renderer to create more specific variants

Public Instance Methods

block_code(code, language) click to toggle source

block level calls

Calls superclass method
# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 17
def block_code(code, language)
    if language == "mermaid"
        %(<div class="mermaid">#{code}</div>)
    else
        super
    end
end
block_quote(quote) click to toggle source
# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 25
def block_quote(quote)
    %(<div class="alert alert-info">#{quote}</div>)
end
image(link, title, alt_text) click to toggle source

def emphasis(text) end

# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 84
        def image(link, title, alt_text)
            <<~IMG
                <img src="#{relative_link link, scope.current_path}" alt="#{alt_text}" class="img-fluid">#{title}</img>
            IMG
        end
paragraph(text) click to toggle source

def list_item(text, list_type) end

# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 50
def paragraph(text)
    definition_list(text.strip)
end
table(header, body) click to toggle source
# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 54
        def table(header, body)
            <<~EOS_TABLE
                <table class='table table-striped table-hover table-sm'>
                    <thead>#{header}</thead>
                    <tbody>#{body}</tbody>
                </table>
            EOS_TABLE
        end

Private Instance Methods

definition_list(text) click to toggle source

def footnote_ref(number) end

# File lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb, line 123
def definition_list(text)
    str = String.new
    re = /^[^:].*?(?:\R: .*)+/
    text.scan(re) do |match|
        list = match.split(":")
        str << "<dt>#{list[0]}</dt>"
        str << "<dd>#{list[1..-1].join("</dd><dd>")}</dd>"
    end

    if str.empty?
        text
    else
        "<dt>#{str}</dl>"
    end
end