<div># render this:</div><div><p>You are logged in as <i>Michael Snoyman</i>, <a</div><div>href="/logout">logout</a>.</p></div><div><p>Multi </div><div> line</div><div> paragraph.</div>
<div></p></div><div><br></div><div><br></div><div># current - explicit</div><div><p>You are logged in as #</div><div> <i>Michael Snoyman</div><div> , #</div><div> <a href="/logout">logout</div>
<div> .</div><div><p>Multi</div><div> \ line</div><div> \ paragraph.</div><div><br></div><div># alternative #! - implicitly add space, explicitly remove on the next line</div><div><p>You are logged in as</div>
<div> <i>Michael Snoyman</div><div> ,</div><div> <a href="/logout">logout</div><div> !.</div><div><p>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><p>You are logged in as</div><div> <i>Michael Snoyman</div><div> ,</div><div> <a href="/logout">logout#</div><div> .</div><div><p>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><p></div><div> You are logged in as</div>
<div> <i>Michael Snoyman</div><div> ,</div><div><br></div><div> <a href="/logout">logout</div><div> .</div><div><p></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 'whitespace alligators'</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># > chomps white space *after* the tag</div><div># < chomps white space *within* the tag</div><div># would need more examples to see if this plays out well</div><div><p>You are logged in as</div><div> <i>Michael Snoyman</div>
<div> ,</div><div> <a href="/logout">logout></div><div> .</div><div><p>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"><<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>></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 <<a href="mailto:patrick@parcs.ath.cx">patrick@parcs.ath.cx</a>> wrote:<br>
> I find it a bit unintuitive that the hamlet code<br>
><br>
> <p>hello<br>
> <strong>there<br>
><br>
> or<br>
><br>
> <p><br>
> hello<br>
> <strong>there<br>
><br>
> generates the html<br>
><br>
> <p>hello<strong>there</strong></p><br>
><br>
> I expected there to be a space between "hello" and "there" similar to what<br>
> the html specifications dictate. Is this behavior intentional or an<br>
> oversight? If it's the former, then what is the recommended way to simulate<br>
> my expected behavior? Appending a space to the end of a line is<br>
> mentally ugly and syntactically obscure.<br>
<br>
</div>I'm not sure what you mean by "what the html specifications dictate."<br>
HTML is whitespace-sensitive, meaning that:<br>
<br>
<i>foo</i> <b>bar</b><br>
<br>
and<br>
<br>
<i>foo</i><b>bar</b><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>
<p>You are logged in as <i>Michael Snoyman</i>, <a<br>
href="/logout">logout</a>.</p><p>Another paragraph.</p><br>
<br>
In the case of the <i> and <a> 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 <p>, we don'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'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 "smart", adding whitespace where it's desired.<br>
<br>
(2) isn'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'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'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's the reasoning behind this stuff, if people have better<br>
ideas, I'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>