Question

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>
Was it helpful?

Solution

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.

OTHER TIPS

There are times when stripping the white space between two tags will make a difference, particularly when dealing with inline elements.

I ran tidy over it and it fixed the unusual linebreaks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top