是否可以创建 HTML quine?
根据标题,是否可以创建一个(不平凡的)quine HTML?
我对 HTML quine 的定义:
假设 HTML 文件中的某些字符串由浏览器呈现为纯文本,则非平凡的 HTML quine 不为 null,并且至少使用一个 HTML 标记。 HTML quine 的定义是,由标准浏览器呈现的
q.html
的输出是q.html
本身的内容。
(我愿意接受对此定义的任何评论,我现在就对它进行了修改)
HTML 不是图灵完备的,因此不能应用定点定理来证明它确实是可能的。
然而,这并不一定意味着 HTML quine 是不可能的。或者实际上可以证明 HTML quine 是不可能的吗?
Per the title, is it possible to create a (non-trivial) quine in HTML?
My definition of an HTML quine:
A non-trivial HTML quine is one that is not null and uses at least one HTML tag, under the assumption that some string in an HTML file is rendered by a browser as plain text. An HTML quine is defined such that the output of the
q.html
as rendered by a standard browser is the contents ofq.html
itself.
(I'm open for any comments on this definition, I kind of hacked it up right now)
HTML is not turing-complete, therefore the fixed-point theorem cannot be applied to prove that it is indeed possible.
However, this does not necessarily mean an HTML quine is impossible. Or can it in fact be proven that an HTML quine is impossible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于“纯”HTML 来说这当然是不可能的。显然,可以使用 JavaScript 来完成,但也可以使用 CSS 来完成:
It's certainly not possible with "plain" HTML. Obviously it would be possible to do with JavaScript, but it's also possible with CSS:
这是不可能的。由于每个未转义的元素都将被浏览器解释为标记,因此浏览器将尝试呈现或处理这些元素的内容或作为控件。您无法显示未以某种方式转义的元素,例如使用
当然,您可以将其作为带有适当 HTTP 标头的文本/纯文本来提供,但这不是 HTML。在大多数(所有?)情况下,仅使用 .html 扩展名将使浏览器将其呈现为 html。
This is not possible. Since every unescaped element will be interpreted as markup by the browser, the browser will attempt to render or handle the contents of those elements or as a control. You cannot display an element that is not escaped in some way, such as with the
<pre>
tag. But then such tags will also not be displayed.Of course, you could serve it as text/plain with appropriate HTTP headers but, then, that's not HTML. Just using the .html extension will make browsers render it as html anyway in most (all?) cases.
你不能。
但你可以作弊并做
You can't.
You can cheat though and do
当然,就像所有 HTML“假设”一样,答案就是使用 JQuery!
Sure, just like with all HTML "what ifs", the answer is just use JQuery!