Class: DocRenderer::Base

Inherits:
Middleman::Renderers::MiddlemanRedcarpetHTML
  • Object
show all
Includes:
InfoHelpers
Defined in:
lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb

Overview

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

Instance Method Summary collapse

Methods included from InfoHelpers

#footer_text, #navbar?, #navbar_brand, #navbar_links, #page_info, #paperwork?, #relative_link, #text_for, #toc?

Instance Method Details

#block_code(code, language) ⇒ Object

block level calls



17
18
19
20
21
22
23
# 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) ⇒ Object



25
26
27
# 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) ⇒ Object

def emphasis(text) end



84
85
86
87
88
# 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

def linebreak() end



93
94
95
# File 'lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb', line 93

def link(link, title, content)
    super(link.gsub(/\.md$/, ".html"), title, content)
end

#paragraph(text) ⇒ Object

def list_item(text, list_type) end



50
51
52
# File 'lib/paperwork/tasks/middleman_template/lib/doc_renderer.rb', line 50

def paragraph(text)
    "<p>#{definition_list(text.strip)}</p>"
end

#table(header, body) ⇒ Object



54
55
56
57
58
59
60
61
# 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