module YARD::Templates::Helpers::HtmlHelper

def parse_codeblocks(html)

Other tags:
    See: #html_syntax_highlight -

Returns:
  • (String) - highlighted html

Parameters:
  • html (String) -- the html to search for code in
def parse_codeblocks(html)
  html.gsub(%r{<pre((?:\s+\w+="(?:.+?)")*)\s*>(?:\s*<code((?:\s+\w+="(?:.+?)")*)\s*>)?(.+?)(?:</code>\s*)?</pre>}m) do
    string = $3
    # handle !!!LANG prefix to send to html_syntax_highlight_LANG
    language, = parse_lang_for_codeblock(string)
    language ||= detect_lang_in_codeblock_attributes($1, $2)
    language ||= object.source_type
    if options.highlight
      string = html_syntax_highlight(CGI.unescapeHTML(string), language)
    end
    classes = ['code', language].compact.join(' ')
    %(<pre class="#{classes}"><code class="#{language}">#{string}</code></pre>)
  end
end