gpt4 book ai didi

html - 是否可以创建 HTML quine?

转载 作者:技术小花猫 更新时间:2023-10-29 12:33:27 25 4
gpt4 key购买 nike

根据标题,是否可以创建一个(非平凡的)quine在 HTML 中?

我对 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 of q.html itself.

(我愿意就此定义发表任何评论,我现在已经把它搞砸了)

HTML 不是图灵完备的,因此不能应用不动点定理来证明它确实是可能的。

然而,这并不一定意味着 HTML quine 是不可能的。或者事实上是否可以证明 HTML quine 是不可能的?

最佳答案

“纯”HTML 肯定是不可能的。显然可以使用 JavaScript,但也可以使用 CSS:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is the title</title>
<style type="text/css"><![CDATA[
* {
display:inline;
white-space:pre;
}
html:last-child {
white-space:normal;
}
html:before {content:'<html xmlns="http://www.w3.org/1999/xhtml">';}
html:after {content:'</html>';}
head:before {content:'<head>';}
head:after {content:'</head>';}
title:before {content:'<title>';}
title:after {content:'</title>';}
style:before {content:'<style type="text/css"><![CDATA[';}
style:after {content:']]\00003e</style>';}
body:before {content:'<body/>';position:absolute;left:0;}
]]></style>
</head>
<body/>
</html>

关于html - 是否可以创建 HTML quine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8400612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com