Hakyll生成了奇怪的HTML - 有人能解释原因吗?

5
我使用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样式之间的区别丢失了。只是提醒其他像我一样困惑的人注意一下。 - Chris
3个回答

5
实际上是由 pandoc 生成HTML代码。在Pandoc问题跟踪器中有很好的解释:http://code.google.com/p/pandoc/issues/detail?id=134 原因是因为HTML标签之间的任何空格(包括换行符和制表符)都会导致浏览器在这些元素之间插入一个空格字符。如果省略这些空格,则对机器逻辑更加容易,因为您不需要考虑HTML文本格式可能影响浏览器添加额外空格的可能方式。

0

有时候去除两个标签之间的空格会有所不同,特别是在处理内联元素时。


0

我运行了Tidy,它修复了不寻常的换行符。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接