Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hakyll generates weird HTML - can anybody explain reason?

I use Hakyll to generate some documentation and I noticed that it has a weird way of closing the HTML tags in the code it generates.

There was a page where they said that you must generate the markup as they do, or the layout of your page will be broken under some conditions, but I can't find it now.

I created a small test page (code below) which has one red layer with the "normal" HTML markup, and a yellow layer with markup similar to what hakyll generates.

I can't see any diference in Firefox between the two divs.

Can anybody explain if what they say is true?

<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>
like image 294
Meh Avatar asked Oct 08 '10 17:10

Meh


1 Answers

It's actually pandoc that's generating the HTML code. There's a good explanation in the Pandoc issue tracker:

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

The reason is because any whitespace (including newline and tabs) between HTML tags will cause the browser to insert a space character between those elements. It is far easier on the machine logic to leave these spaces out, because then you don't need to think about the possible ways that the HTML text formatting could be messing with the browser adding extra spaces.

like image 130
Cosmin Lehene Avatar answered Oct 18 '22 00:10

Cosmin Lehene