Sha256: 105fac52880a9796f14bcb182e8869c96504dbf54d9a04fdedeec5e42f327394
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
module Kitabu module Helpers def highlight_theme(name = theme) html = '<style type="text/css">' html << Rouge::Theme.find(name).render(scope: '.highlight') html << '</style>' html end def image_tag(path, attributes = {}) html = %[<img src="images/#{path}" />] end def escape_html(content) CGI.escape_html(content.to_s) end def note(class_name = :info, &block) content = block_content(block) output << '<div class="note %s">' % escape_html(class_name) output << markdown(content) output << '</div>' end def block_content(block) output, @_output = @_output.dup, '' content = block.call @_output = output content end def markdown(content, deindent_content = true) content = deindent(content) if deindent_content Markdown.render(content) end def deindent(content) content = content.to_s indent = (content.scan(/^[ \t]*(?=\S)/) || []).size content.gsub(/^[ \t]{#{indent}}/, '') end def output @_output end end end
Version data entries
6 entries across 6 versions & 1 rubygems