line breaks and indentation in html output
<p>Recently I was printing out some HTML source for a project I've been working on. I like to keep my markup tidy and readable. I noticed that in some places there are no line breaks on the outputted html and in some places there is excess indentation. For example take the following code, where I have preserved the indentation from the source file:</p>

<pre><code>    &lt;div id="sections"&gt;
    &lt;ul&gt;
    &lt;?php if(!empty($details)) { ?&gt;
        &lt;li&gt;&lt;a href="#details"&gt;&lt;span&gt;Details&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

    &lt;?php } if(!empty($address) { ?&gt;
        &lt;li&gt;&lt;a href="#viewmap"&gt;&lt;span&gt;Location Map&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

    &lt;?php } if(!empty($reviews) { ?&gt;
        &lt;li&gt;&lt;a href="#reviews"&gt;&lt;span&gt;Reviews (&lt;?php echo $numrows; ?&gt;)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

    &lt;?php } if($email != null) { ?&gt;
        &lt;li&gt;&lt;a href="#sendemail"&gt;&lt;span&gt;Send an Email&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;?php } ?&gt;
    &lt;/ul&gt;
</code></pre>

<p>The generated HTML output is as follows:</p>

<pre><code>    &lt;div id="sections"&gt;
    &lt;ul&gt;
                &lt;li&gt;&lt;a href="#details"&gt;&lt;span&gt;Details&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

                &lt;li&gt;&lt;a href="#viewmap"&gt;&lt;span&gt;Location Map&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;

                &lt;li&gt;&lt;a href="#sendemail"&gt;&lt;span&gt;Send an Email&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
    &lt;/div&gt;
</code></pre>

<p>Here we can see the DIV and UL tags have two tab indents from the left - this is fine. However the LI tags have 5 indents from the left - it should only be 3 if it goes according to my code. The end UL tag also has two extra indents.</p>

<p>Is this just the expected behaviour or can this be rectified somehow?</p>
