class Playbook::Markdown::HTMLBlockCode
def header(title, level)
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
def image(link, title, alt_text)
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
def table(header, body)
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