<div># render this:</div><div>&lt;p&gt;You are logged in as &lt;i&gt;Michael Snoyman&lt;/i&gt;, &lt;a</div><div>href=&quot;/logout&quot;&gt;logout&lt;/a&gt;.&lt;/p&gt;</div><div>&lt;p&gt;Multi </div><div>  line</div><div>  paragraph.</div>

<div>&lt;/p&gt;</div><div><br></div><div><br></div><div># current - explicit</div><div>&lt;p&gt;You are logged in as #</div><div>  &lt;i&gt;Michael Snoyman</div><div>  , #</div><div>  &lt;a href=&quot;/logout&quot;&gt;logout</div>

<div>  .</div><div>&lt;p&gt;Multi</div><div>  \ line</div><div>  \ paragraph.</div><div><br></div><div># alternative #! - implicitly add space, explicitly remove on the next line</div><div>&lt;p&gt;You are logged in as</div>

<div>  &lt;i&gt;Michael Snoyman</div><div>  ,</div><div>  &lt;a href=&quot;/logout&quot;&gt;logout</div><div>  !.</div><div>&lt;p&gt;Multi</div><div>  line</div><div>  paragraph.</div><div><br></div><div><br></div><div># alternative #2 - implicitly add space, explicitly remove on the current line</div>

<div>&lt;p&gt;You are logged in as</div><div>  &lt;i&gt;Michael Snoyman</div><div>  ,</div><div>  &lt;a href=&quot;/logout&quot;&gt;logout#</div><div>  .</div><div>&lt;p&gt;Multi</div><div>  line</div><div>  paragraph.</div>

<div><br></div><div><br></div><div><div># alternative #3 - implicitly add space when there is a new line before tag contents</div><div># seems bad, just throwing it out there :)</div><div>&lt;p&gt;</div><div>  You are logged in as</div>

<div>  &lt;i&gt;Michael Snoyman</div><div>  ,</div><div><br></div><div>  &lt;a href=&quot;/logout&quot;&gt;logout</div><div>  .</div><div>&lt;p&gt;</div><div>  Multi</div><div>  line</div><div><br></div><div>  paragraph.</div>

<div><br></div><div><br></div><div># alternative #4 - implicitly add space. remove space with &#39;whitespace alligators&#39;</div><div># somewhat similar to: <a href="http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#whitespace_removal__and_">http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#whitespace_removal__and_</a></div>

<div># &gt; chomps white space *after* the tag</div><div># &lt; chomps white space *within* the tag</div><div># would need more examples to see if this plays out well</div><div>&lt;p&gt;You are logged in as</div><div>  &lt;i&gt;Michael Snoyman</div>

<div>  ,</div><div>  &lt;a href=&quot;/logout&quot;&gt;logout&gt;</div><div>  .</div><div>&lt;p&gt;Multi</div><div>  line</div><div>  paragraph.</div></div><div><br></div><br><div class="gmail_quote">On Thu, May 19, 2011 at 8:57 PM, Michael Snoyman <span dir="ltr">&lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Thu, May 19, 2011 at 11:49 PM, Patrick Palka &lt;<a href="mailto:patrick@parcs.ath.cx">patrick@parcs.ath.cx</a>&gt; wrote:<br>


&gt; I find it a bit unintuitive that the hamlet code<br>
&gt;<br>
&gt; &lt;p&gt;hello<br>
&gt;    &lt;strong&gt;there<br>
&gt;<br>
&gt; or<br>
&gt;<br>
&gt; &lt;p&gt;<br>
&gt;     hello<br>
&gt;     &lt;strong&gt;there<br>
&gt;<br>
&gt; generates the html<br>
&gt;<br>
&gt; &lt;p&gt;hello&lt;strong&gt;there&lt;/strong&gt;&lt;/p&gt;<br>
&gt;<br>
&gt; I expected there to be a space between &quot;hello&quot; and &quot;there&quot; similar to what<br>
&gt; the html specifications dictate. Is this behavior intentional or an<br>
&gt; oversight? If it&#39;s the former, then what is the recommended way to simulate<br>
&gt; my expected behavior? Appending a space to the end of a line is<br>
&gt; mentally ugly and syntactically obscure.<br>
<br>
</div>I&#39;m not sure what you mean by &quot;what the html specifications dictate.&quot;<br>
HTML is whitespace-sensitive, meaning that:<br>
<br>
   &lt;i&gt;foo&lt;/i&gt; &lt;b&gt;bar&lt;/b&gt;<br>
<br>
and<br>
<br>
    &lt;i&gt;foo&lt;/i&gt;&lt;b&gt;bar&lt;/b&gt;<br>
<br>
Are different. Now, in all likelihood in the above example, you will<br>
want to have the whitespace surrounding tags. But consider the<br>
following HTML:<br>
<br>
    &lt;p&gt;You are logged in as &lt;i&gt;Michael Snoyman&lt;/i&gt;, &lt;a<br>
href=&quot;/logout&quot;&gt;logout&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Another paragraph.&lt;/p&gt;<br>
<br>
In the case of the &lt;i&gt; and &lt;a&gt; tags, we definitely do *not* want to<br>
add whitespace after the tag (though we do want it before the tag). In<br>
the case of &lt;p&gt;, we don&#39;t care one way or another, but adding the<br>
whitespace everywhere will take up (a trivial amount of) extra<br>
bandwidth. tl;dr: Sometimes you don&#39;t want the whitespace.<br>
<br>
So when designing Hamlet, I thought up a few possibilities:<br>
<br>
1) What we do now: all whitespace must be explicit.<br>
2) Implicitly add whitespace before/after every tag.<br>
3) Do something &quot;smart&quot;, adding whitespace where it&#39;s desired.<br>
<br>
(2) isn&#39;t really an option because it makes having a tag as the last<br>
word in a sentence impossible. (3) gives me the creeps: I like smart<br>
libraries, but I will *never* trust a library to do this kind of stuff<br>
correctly all the time, even if I&#39;m the one making up the rules for it<br>
to follow! And I have no doubt that it will quickly devolve into 500<br>
lines of hairy code to try and cover millions of corner cases. Oh, and<br>
don&#39;t forget that there are other languages than English that might<br>
approach it differently.<br>
<br>
I suppose another possibility is (2) along with some special way of<br>
forcing the removal of extra whitespace, but this seemed much less<br>
intuitive than the current approach.<br>
<br>
Anyway, that&#39;s the reasoning behind this stuff, if people have better<br>
ideas, I&#39;d like to hear them.<br>
<font color="#888888"><br>
Michael<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
web-devel mailing list<br>
<a href="mailto:web-devel@haskell.org">web-devel@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/web-devel" target="_blank">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
</div></div></blockquote></div><br>