嘿,我正在使用 Coderay 和 Redcarpet 进行语法高亮和解析标记。
请。建议一种方法来摆脱 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