Show HN: This page is a truly naked, brutalist HTML quine
secretgeek.github.io
secretgeek.github.io
Until today I wondered why on Earth "quine" might mean "A program that outputs its own source" and it turns out to be a tribute to a guy called Quine who did a lot of work on self-referential logic.
* {
display: block;
}
making literally every element visible (including stuff like <head> or <script>). The rest is just CSS ::before and ::after inserting tag's names. style::before {content:'<style>'}
style::after {content:'<\/style>'}
I don't think it's a bug. After all, browsers have very lenient parsers and if there's a syntax error (unterminated quote) in the style it shouldn't affect the rest of the HTML. The same goes for JavaScript: you probably still can't use the string literal '</script>' within an inline script.You're right: https://jsfiddle.net/pLo9bdhs
If CSS and JS syntax were to decide when the end tags can appear, some malformed CSS or JS would break the end tag and cause the entire rest of the document to vanish as the browser wouldn't recognise it as HTML.
Short answer is standard says to parse the contents of <style> elements as text.
Long answer is style start tag triggers [1] the generic raw text element parsing algorithm [2] which switches the parsers insertion mode to "text" [3] which only exits once an end tag is seen. Given that the generic raw text element parsing algorithm switched the tokenizer to RAWTEXT state [4] it will only output an end tag token from the RAWTEXT end tag name state [5] for an appropriate end tag token [6] which by definition will be "</style>"
[1] https://html.spec.whatwg.org/#parsing-main-inhead [2] https://html.spec.whatwg.org/#generic-raw-text-element-parsi... [3] https://html.spec.whatwg.org/#parsing-main-incdata [4] https://html.spec.whatwg.org/#rawtext-state [5] https://html.spec.whatwg.org/#rawtext-end-tag-name-state [6] https://html.spec.whatwg.org/#appropriate-end-tag-token
Then again the HTML5 spec is based on what browsers already did, bugs included. Whether or not it's desirable behaviour or a bug is a moot point now. HTML is the way it is because of its history.
Ed: i guess in this case 1 rem is roughly 2 em (styled element has 50% font size) - and 1 ch is roughly 1 em?
*::before, *::after {
user-select: text; // or `all`?
}This process has taught some interesting things about browsers. For example: `<br>` and `<img />` elements are "replaced" and can't really be shown in the way all other elements are. (I conveniently avoided using them).
And, as described above, ::before/::after content cannot be selected, and generally behave... strangely.
Did you see any variance between browsers? Hopefully not, with "common" CSS like this, but it would be interesting.
This would also alleviate the need to use CSS, and in particular the repetitive CSS.
It would also allow the tags/attributes to be styled in a more idiomatic way.
But i'm out of time on this idea ;)
https://no-gravity.github.io/html-quine/index.html
I am getting some additional empty lines in the output. And the closing html tag is missing. Any ideas why?
End of the source:
</body>
</html>
Rendered in the browser as: </body>
</html> margin:1.5em 0
When there was no margin the text was quite ugly and hard to read. Then tried margin 1em and it was better. Pushing it out to 1.5em really did the trick.FYI: There's a typo in the word "necessary" (it has double C's and double R's in the original copy).
The first was a postcard from my grandparents’ church thanking me for attending their service “last Sinday”. I regret I eventually lost that card.
My favorite was an on-air editorial from a local student-run public radio station. The young woman was lamenting the grief her fellow broadcasters were receiving from the community about pronunciation.
Either deliberately or regrettably, she consistently mispronounced “mispronunciation” by using /ow/ instead of /uh/ for the third syllable.
I miss WAJC. Great eclectic music selection, but Butler University sold it about 25 years ago to fund a TV studio instead.
It was a truly brutalists experience to see some things more exposed than I was prepared to.
As a side note, I just played through console.log(), and I thought you might want to know that there's an unnecessary apostrophe in the winning text! Of course I only saw it after also discovering, I believe, every possible way to die.
edit: I've submitted a pull request.
Being able to make scripts and other elements visible by putting 'display: block' on them is the more useful thing that I learned.
Based on your advice I changed these words:
> Viewing the source of this page should
...to be:
> Viewing <a href='https://raw.githubusercontent.com/secretGeek/html_wysiwyg/ma... source</a> of this page should
https://secretgeek.github.io/html_wysiwyg/html.css
...but it will need more added to it, depending on the elements and attributes that you want to cover.
> …to speed up page loads, eliminate clutter…
Thanks to all for your concerns of my potentially malware-infected PC, alas, it was just an ad-blocker.