- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在使用 Maruku (Ruby) 来解析一些 Markdown 格式的文本。我在尝试像这样格式化一段 code
时遇到问题:
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 输入,它的呈现方式与我预期的一样(也就是说,两行代码都在一个 block 中,都在同一级别缩进)。但对于 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
然后它会为我正确呈现。
关于html - Maruku 错误地解析了第二行代码块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6325416/
我正在使用 Maruku (Ruby) 来解析一些 Markdown 格式的文本。我在尝试像这样格式化一段 code 时遇到问题: This is a normal line # pretend th
我在原始 Markdown 文件中遇到了一些语法,我认为这可能是 Maruku 特有的: +--{.abstract} ### Abstract Lorem ipsum dolor sit amet,
我在 Rails 中使用 Maruku 只是为了将 Markdown 文件转换为 HTML,以便我可以将它与 Nokogiri 一起使用。 (也许有更好的解决方案?)这很好用,但我在日志中收到很多很多
我在我的 RoR3 应用程序中使用 Maruku。但问题是,当我在使用 Maruku 之前使用 h(text) 方法从数据库中转义文本时,它会将 > 转义为 > 所以 Maruku 不会将其视为 bl
如何让 Jekyll/Maruku 告诉我哪个文件存在 Markdown 语法错误? 构建警告只告诉我这么多: $ jekyll --safe Configuration from /homne/me
我是一名优秀的程序员,十分优秀!