Maruku错误地解析了第二行代码块?

| 我正在使用Maruku(Ruby)解析一些Markdown格式的文本。尝试像这样格式化“ 0”块时遇到问题:
This is a normal line
# pretend this line is empty
    printf(\"First line of code is OK\");
    printf(\"Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!\");
所以我的第一行代码(我在md文件中缩进了4个空格(或一个制表符),就像我期望的那样呈现。但是,我的第二行代码(缩进了相同数量的空格)最终会在生成HTML时缩进4个空格。 输出看起来像这样:
This is a normal line
<pre><code>printf(\"First line of code is OK\");
      printf(\"Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!\");</code></pre>
我已经使用Gruber的\“ Dingus \”测试了我的Markdown输入,它按照我的期望进行渲染(也就是说,两行代码在一个块中,都在同一级别缩进)。但是有了Maruku,这真是铺张了床。 我也尝试过使用RDiscount,但效果相同。我使用Maruku是因为我需要定义列表。 SO如何格式化: 这是一条正常线
printf(\"First line of code is OK\\n\");
printf(\"Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!\");
    
已邀请:
        事实证明,这不是Maruku问题,而是HAML问题。 关于空格和保留空格,HAML非常挑剔。解决方案是在渲染时使用
= preserve @my_html_string
。 例如,给定
layout.haml
!!! 5
%html
    %body
        = yield
index.haml
%article
    = preserve @my_html_fragment_with_pre_and_code
然后它将为我正确呈现。     

要回复问题请先登录注册