Hakyllは奇妙なHTMLを生成します - 誰かが理由を説明できますか?
-
28-09-2019 - |
質問
Hakyllを使用していくつかのドキュメントを生成し、生成するコードのHTMLタグを閉じる奇妙な方法があることに気付きました。
彼らがマークアップを生成する必要があると言ったページがありました。または、ページのレイアウトはいくつかの条件下で壊れますが、今は見つかりません。
「通常の」HTMLマークアップを備えた1つの赤い層と、Hakyllが生成するものと同様のマークアップを備えた黄色の層を持つ小さなテストページ(以下のコード)を作成しました。
2つのDivの間にFirefoxの違いはありません。
彼らが言うことが真実かどうかを誰かが説明できますか?
<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>
解決
それは実際です パンドク それはHTMLコードを生成しています。 Pandoc Issue Trackerには良い説明があります。
http://code.google.com/p/pandoc/issues/detail?id=134
その理由は、HTMLタグ間の白人(NewlineとTabsを含む)が、ブラウザがそれらの要素間にスペース文字を挿入するようになるためです。マシンのロジックでは、これらのスペースを除外する方がはるかに簡単です。なぜなら、HTMLテキストのフォーマットがブラウザが追加のスペースを追加することをいじくり回す可能性のある方法について考える必要がないからです。
他のヒント
特にインライン要素を扱うとき、2つのタグ間で白い空間を剥ぎ取ると違いが生じる場合があります。
私はそれを整頓し、それは珍しいラインブレイクを修正しました。
所属していません StackOverflow