TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fixed-Point HTML

61 pointsby tahouptover 2 years ago

10 comments

eyelidlessnessover 2 years ago
I’m surprised to see the highlights don’t include another common detail of the parsing algorithm that often trips people up: table rows and cells (tr&#x2F;th&#x2F;td) must be in one of thead&#x2F;tbody&#x2F;tfoot. If they’re not, they’re implicitly nested into a tbody. As in:<p><pre><code> &lt;table&gt; &lt;!-- &lt;tbody&gt; --&gt; &lt;tr&gt; &lt;th&gt;Column one&lt;&#x2F;th&gt; &lt;th&gt;Column two&lt;&#x2F;th&gt; &lt;&#x2F;th&gt; &lt;tr&gt; &lt;td&gt;Row one col one&lt;&#x2F;td&gt; &lt;td&gt;Row one col two&lt;&#x2F;td&gt; &lt;&#x2F;th&gt; &lt;!-- &lt;&#x2F;tbody&gt; --&gt; &lt;&#x2F;table&gt; </code></pre> I’ve frequently seen it cause a variety of issues with VDOM libraries, and even plain DOM libraries with a notion of declarative templates, ranging from hydration mismatch logs (meh) to actual logic errors (corruption of the real DOM when nodes aren’t where they’re expected to be).<p>Other implied&#x2F;omitted tags like body can cause similar issues too, but I think that’s become a far less common “mistake” (all of these are totally <i>valid</i> since at least HTML5) in recent years.
评论 #32969458 未加载
skybrianover 2 years ago
Perhaps a more intuitive name would be &quot;round-trip serialization HTML&quot;. That is, if you use the browser to parse and print some HTML, it matches the source code.<p>Or in other words, it&#x27;s formatted the same way that the browser would do it. So, you use the browser to pretty-print the HTML page, and save the code as the source. It&#x27;s not hard at all and could be done automatically.<p>Round-trip tests are often used to check that a deserialization routine outputs data that can be serialized again and no data is lost. It even lets you change the serialization format, provided that you change the parser and printer to match.<p>I expect that these sort of tests are a lot more useful with fuzzing, though. Finding one example that works mostly just tells you that the browser&#x27;s HTML printing code isn&#x27;t completely broken. A single test of that sort is only useful for catching stupid bugs quickly.
kazinatorover 2 years ago
This is called print-read consistency in the Lisp world: an object is printed in such a way that the syntax can be read to produce a similar object, or else is given a deliberately unreadable notation like #&lt;...&gt;, where the #&lt; combination is required to produce a read error.<p><a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;70797208&#x2F;what-is-print-read-consistency" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;70797208&#x2F;what-is-print-r...</a>
评论 #32969528 未加载
PaulStateznyover 2 years ago
&gt; Why write Fixed-Point HTML?<p>&gt; simply the satisfaction of knowing that you and the browser are in total agreement<p>So, just to clarify: there&#x27;s no technical benefit, correct?
评论 #32968210 未加载
评论 #32968169 未加载
评论 #32968106 未加载
tomxorover 2 years ago
&gt; the real reason to code in Fixed-Point HTML is simply the satisfaction of knowing that you and the browser are in total agreement about the HTML.<p>Interesting idea, I&#x27;ve been trying to achieve something similar but in reverse... rather than make my source match the browser, make the browser match my source by making it <i>not</i> ignore spacing.<p>i.e The basics being `white-space: pre;` on the body element, and fixed width and sized fonts. But I still want a HTML document so i can opt in to html where it matters. My reasons are to A) avoid a pre-processor and build toolchain complexity, stick to nice simple static files, and B) I get something similar to WYSIWYG but as source code. C) I like fixed width fonts and to plain text formatting (reducing decisions is helpful for focus).
评论 #32968127 未加载
tfshover 2 years ago
Before now I&#x27;ve explicitly reduced the size of my HTML docs (nothing critical&#x2F;production facing, all passion projects) by removing certain HTML tags (e.g DOCTYPE, closing tags, etc) because I know modern browsers will still render them correctly.<p>This means there are miniscule savings from a bandwidth serving perspective. I wonder what the trade off is between the HTTP call and document parse&#x2F;paint.<p>E.g is it correct to assume the browser will parse&#x2F;paint the HTML content - fixing incorrectly closed tags on the fly faster than the few milliseconds more it would take to serve fixed-point HTML from the server?
pushedxover 2 years ago
Interesting concept.<p>On latest Chrome, the &quot;Check Fixed-Point&quot; button appears to fail.
评论 #32968118 未加载
评论 #32968307 未加载
评论 #32968093 未加载
WirelessGigabitover 2 years ago
XML-flavored self-closing elements are banished (use &lt;br&gt; instead of &lt;br &#x2F;&gt;)<p>God I hate that. It just doesn’t make sense. Where is the &lt;br&gt; closed?
评论 #32986389 未加载
bhedgeoserover 2 years ago
Fixed-point check failed on chrome 104.0.5112.101
评论 #32968260 未加载
exabrialover 2 years ago
Basically: xhtml is fast and verifiable?
评论 #32969383 未加载