Class: Playbook::Markdown::HTMLBlockCode
- Inherits:
-
Redcarpet::Render::HTML
- Object
- Redcarpet::Render::HTML
- Playbook::Markdown::HTMLBlockCode
- Includes:
- ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/playbook/markdown/helper.rb
Instance Method Summary collapse
- #header(title, level) ⇒ Object
- #image(link, title, alt_text) ⇒ Object
-
#table(header, body) ⇒ Object
def block_code(code, language) “n.nfn#language))n.fin” end.
Instance Method Details
#header(title, level) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/playbook/markdown/helper.rb', line 108 def header(title, level) @headers ||= [] permalink = title.gsub(/\W+/, "-") if @headers.include?(permalink) permalink += "_1" loop do break unless @headers.include?(permalink) permalink.gsub!(/_(\d+)$/, "_#{Regexp.last_match(1).to_i + 1}") end end @headers << permalink permalink_markup = %(<a name="#{permalink}" class="markdown-header-anchor" ) permalink_markup += %(href="##{permalink}"><span class="far fa-link markdown-header-anchor-icon"></span></a>) %(\n<h#{level} id="#{permalink}">#{title} #{permalink_markup}</h#{level}>\n) end |
#image(link, title, alt_text) ⇒ Object
125 126 127 128 129 |
# File 'lib/playbook/markdown/helper.rb', line 125 def image(link, title, alt_text) return nil if link.nil? %(<a href="#{link}" target="_blank">#{image_tag(link, title: title, alt: alt_text, class: 'imageloader lazyload')}</a>) end |
#table(header, body) ⇒ Object
def block_code(code, language)
"\n.nf\n#{normal_text(rouge(code, language))}\n.fi\n"
end
101 102 103 104 105 106 |
# File 'lib/playbook/markdown/helper.rb', line 101 def table(header, body) "<table class='pb_table table-sm table-responsive-collapse table-card table-collapse-sm'>" \ "<thead>#{header}</thead>" \ "<tbody>#{body}</tbody>" \ "</table>" end |