def htmlify(text, markup = options[:markup])
markup_meth = "html_markup_#{markup}"
return text unless respond_to?(markup_meth)
return "" unless text
return text unless markup
html = send(markup_meth, text)
if html.respond_to?(:encode)
html = html.force_encoding(text.encoding)
html = html.encode(:invalid => :replace, :replace => '?')
end
html = resolve_links(html)
html = html.gsub(/<pre\s*(?:lang="(.+?)")?>(?:\s*<code>)?(.+?)(?:<\/code>\s*)?<\/pre>/m) do
language = $1
string = $2
string = html_syntax_highlight(CGI.unescapeHTML(string), language) unless options[:no_highlight]
classes = ['code', language].compact.join(' ')
%Q{<pre class="#{classes}">#{string}</pre>}
end unless [:text, :none, :pre].include?(markup)
html
end