【问题标题】:Hakyll generates weird HTML - can anybody explain reason?Hakyll 生成奇怪的 HTML - 任何人都可以解释原因吗?
【发布时间】:2010-10-08 17:55:32
【问题描述】:

我使用 Hakyll 生成一些文档,我注意到它有一种奇怪的方式来关闭它生成的代码中的 HTML 标签。

有一个页面,他们说你必须像他们一样生成标记,否则在某些情况下你的页面布局会被破坏,但我现在找不到。

我创建了一个小测试页面(代码如下),其中有一个带有“正常”HTML 标记的红色层,以及一个带有类似于 hakyll 生成的标记的黄色层。

我在 Firefox 中看不出两个 div 有什么区别。

谁能解释他们说的是不是真的?

<html>
<body>
<!-- NORMAL STYLE -->
<div style="background: red">
<p>Make available the code from the library you added to your application. Again, the way to do this varies between languages (from adding import statements in python to adding a jar to the classpath for java)</p>
<p>Create an instance of the client and, in your code, make calls to it through this instance's methods.</p>
</div>
<!-- HAKYLL STYLE -->
<div style="background: yellow"
><p
>Make available the code from the library you added to your application. Again, the way to do this varies between languages (from adding import statements in python to adding a jar to the classpath for java)</p
><p
>Create an instance of the client and, in your code, make calls to it through this instance's methods.</p
></div
>
</body>
<html>

【问题讨论】:

  • 看起来这个问题被编辑了,以至于普通风格和Hakyll风格之间的区别消失了。只是为其他像我一样困惑的人提一下。

标签: html markup template-engine hakyll


【解决方案1】:

实际上是pandoc 生成了HTML 代码。 Pandoc问题跟踪器中有一个很好的解释:

http://code.google.com/p/pandoc/issues/detail?id=134

原因是 因为 HTML 标记之间的任何空格(包括换行符和制表符)都会导致 浏览器在这些元素之间插入一个空格字符。这要容易得多 机器逻辑将这些空间排除在外,因为那样你就不需要考虑 HTML文本格式可能与浏览器混淆的可能方式添加 多余的空格。

【讨论】:

    【解决方案2】:

    有时去除两个标签之间的空白会产生影响,尤其是在处理内联元素时。

    【讨论】:

      【解决方案3】:

      我整理了一下,它修复了不寻常的换行符。

      【讨论】:

        猜你喜欢
        • 2011-03-31
        • 1970-01-01
        • 2011-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多