Live data from Hacker News

Write HTML Right

lofi.limo

211–212 of 212 posts

Re: Write HTML Right

#211

Earlier quoted context omitted.

Lenient parsers still benefit from strict input because it lets them avoid lookaround/backtracking.

What do you mean by lookaround/backtracking? You're inside . You encounter another . You can't nest one inside another , so you close current and open new . That's about it. I fail to see where do you need any kind of backtracking.

Well, even in this one example, imagine parser combinators which often mean backtracking the inner

so that you can commit to the `openTag('p')` parser. Or your logic may be 'consume all tags that aren't

` which is a lookahead.

A better example here is whether you are lenient and accept unescaped html entities like "<" vs "&lt;". If you require it to be escaped "&lt;" or if all entities in your inputs are always escaped, then your text parser never has to backtrack. But if you are lenient, your text parser can do catastrophic levels of backtracking if there is a single "<" somewhere (unless you are careful). Imagine input that starts off "<a small mouse once said". If could be quite a while before your parser knows it's not an anchor open tag.

Re: Write HTML Right

#212

Earlier quoted context omitted.

Well, one simply formats the source file as you write it. The other requires a infile -> outfile build step that's more complex. Whether the latter is worth it tends to depend on other things than parse time.

Why would I care if one is merely “formatting” or not? If I have to run a tool either way, I would prefer one that accepts a user-friendly input language and decouples content from presentation.

Because transforming an .md file into an .html file is a lot more invasive (though taken for granted here I think) than just writing the .html file. It's a build step where there wasn't one before.

I'm not saying it's never worth it.

Post reply on HN