嘿,我正在使用Coderay和Redcarpet进行语法突出显示和解析标记。
PLS。建议一种摆脱div中指示的前导空格的方法(参考图像)
class CodeRayify < Redcarpet::Render::HTML
def block_code(code, language)
CodeRay.scan(code, language).div
end
end
def markdown(text)
coderayified = CodeRayify.new(:filter_html => true,
:hard_wrap => true)
options = {
:fenced_code_blocks => true,
:no_intra_emphasis => true,
:autolink => true,
:superscript => true,
:strikethrough => true,
:no_styles => true
}
markdown_to_html = Redcarpet::Markdown.new(coderayified, options)
markdown_to_html.render(text).html_safe
end