The thing I hate about HTML
blog.jgc.org
blog.jgc.org
<b>bold only, <i>bold-italic,</b> italic only</i>
But that's so ridiculously rare in practice (and totally messes with things like DOM traversal) that nobody missed it in XHTML, which, like its XML ancestor, requires a pure tree structure. Yet XML still requires named end tags, and so does modern HTML.You can of course generate HTML from S-expressions, most Lisps have libraries for it. I particularly like the Clojure notation of
['tagname {:attrname "attrvalue"} child-nodes...]
where {} denotes a map literal, but even if you use that, your client JavaScript deals with the emitted ugly HTML.
The biggest problem I have with HTML and CSS, though, is that they're both designed for marking up text, not websites. Divs and such are an afterthought.
Tangent: I failed trying to leave a comment on the blog proper. Some kind of internal error delivering the comment.
http://code.google.com/p/zen-coding/
As far as ending tags go, HTML actually allows optional closing tags in some elements (http://www.w3.org/TR/html401/index/elements.html) and the proposed idea of using </> would cause confusion:
<ul>
<li>bla
</> <- what did I close here?This was covered in TFA, except that JGC apparently thinks that having optional tags is an attempt at DWIM that’s more trouble than it’s worth:
> The browser magically says: “Oh, he must have meant to close that <p> tag so I'll do it for him.” [...] Given that the tags are meant to be balanced there's no reason to force the author to figure out which tags they want to balance and force them to write it down. It adds nothing.
Personally, though, I think implicit end tags are just fine, as long as they’re clearly documented and browsers have a standardized & predictable parsing approach.
Not exactly... he basically said "let's drop the current spec and use lisp".
The thing I noticed when looking at language design though is that it's really easy to say "language X should look like Y" but overlook something that makes the whole proposal a really bad idea. Case in point: can you spot the problems on his lisp example? (hint: elements vs text nodes, required escape sequences)
I also hope his examples were more like a sketch than a careful proposal – otherwise, as you said, there’s a lot of ambiguity.
Anyway, there are clear advantages and disadvantages to both models. I’m not personally convinced that either HTML or S-expressions is an especially good document format, at least not as far as a human trying to create a document is concerned, but fortunately these kinds of languages are easy enough to generate that the original source language can pretty much look like whatever someone can imagine.
i do prefer to do my html creation in an intermediate language that deals with closing tags and what not for me. be it a template language etc that can be used at deployment time to create properly formatted html from an intermediate language that is less error prone.
i love haml, and sass, since it's just speeds up development several times, improves readability and eases the whole process.
things i really like:
clojure's basic html creation. seaside's basic html creation.
i haven't done anything beyond toy projects with clojure so far. mostly lurking on the mailing list for quite a while. i assume by 'our world', you meant the clojure world. if yes, can you give some insight into the fresh air that people coming from ruby brought to the clojure community?
</a>
</li>
</ul>
</tr>
</td>
</tbody>
</table>
</div><!-- End of #section-nav -->
Would it be a horrible thing if HTML supported an optional id or class attribute in the closing tag? </div id="section-nav">
Of course it would have to match to validate. Probably not realistic in that my guess is this wouldn't be SGML-backwards compatible.* You can't write lowercase letters without the possibility of it being mistaken for a tag. If I write (hello) and then a <hello> tag is introduced, I'm screwed.
* Parentheses are common in written English. It would be better to use [] {} or <>.
What you could do is substitute () for [] and use a : to introduce character data:
[font color="red"
[center:
hello, world!
]
]
But people would be forgetting that all the time. Another option is significant newlines. That is, if a trimmed line doesn't start with a "[", it is interpreted as character data: [font color="red"
[center
hello, world
]
]
Combined with the : to introduce character data, this is actually kind of good: [font color="red"
[center
hello, [em:world]!
[img src="photo.png"]
]
]
Compared to <font color="red">
<center>
hello, <em>world</em>!
<img src="photo.png">
</center>
</font>I know very little about Lisp, so this type of thing might already exist.
A bunch can be found here: http://www.cliki.net/Lisp%20Markup%20Languages
Examples: http://www.cliki.net/HTML-TEMPLATE http://www.nicklevine.org/play/xhtml.lisp http://www.cliki.net/yaclml http://www.cliki.net/CL-WHO
as a basic example from seaside:
renderContentOn: html
html heading level: 1; with: 'Hello World!'.
creates<h1>Hello World</h1>
More on how Seaside generates html can be found at:
http://seaside.st/documentation/generating-html
Here is an example from racket ( aka plt scheme ):
(define (build-request-page label next-url hidden) `(html (head (title "Enter a Number to Add")) (body ([bgcolor "white"]) (form ([action ,next-url] [method "get"]) ,label (input ([type "text"] [name "number"] [value ""])) (input ([type "hidden"] [name "hidden"] [value ,hidden])) (input ([type "submit"] [name "enter"] [value "Enter"]))))))
More ( and the proper formatting of the above ) can be seen at:
http://docs.racket-lang.org/more/#(part.__.Hello_.World__.Se...
* There's Builders in Groovy (http://groovy.codehaus.org/Builders)
* Markaby in Ruby (http://en.wikipedia.org/wiki/Markaby)
* and Markapl and Template::Declare in Perl (http://search.cpan.org/perldoc/Markapl & http://search.cpan.org/perldoc/Template%3A%3ADeclare).
Here is the snippet in blogpost using Markapl:
div('.red') {
p { "hello world" }
}
Also see related HN: http://news.ycombinator.com/item?id=705698