Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 2c1a0e0

Browse files
tweaked example file
1 parent 7a8525d commit 2c1a0e0

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

examples/quine.html

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<!-- The defer is not necessary for autoloading, but is necessary for the
77
script at the bottom to work as a Quine. -->
88
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?autoload=true&skin=sunburst&lang=css" defer="defer"></script>
9+
<style>.operative { font-weight: bold; border:1px solid yellow }</style>
910
</head>
1011

1112
<body>
@@ -31,12 +32,24 @@ <h1>Making Quines Prettier</h1>
3132
<?prettify lang=html linenums=true?>
3233
<pre class="prettyprint" id="quine" style="border:4px solid #88c"></pre>
3334

34-
<script>
35-
//<![CDATA[
36-
document.getElementById("quine").appendChild(document.createTextNode(
35+
<script>//<![CDATA[
36+
(function () {
37+
function html(s) {
38+
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
39+
}
40+
41+
var quineHtml = html(
3742
'<!DOCTYPE html>\n<html>\n'
38-
+ document.documentElement.innerHTML
39-
+ '\n<\/html>\n'));
43+
+ document.documentElement.innerHTML
44+
+ '\n<\/html>\n');
45+
46+
// Highlight the operative parts:
47+
quineHtml = quineHtml.replace(
48+
/&lt;script src[\s\S]*?&gt;&lt;\/script&gt;|&lt;!--\?[\s\S]*?--&gt;|&lt;pre\b[\s\S]*?&lt;\/pre&gt;/g,
49+
'<span class="operative">$&</span>');
50+
51+
document.getElementById("quine").innerHTML = quineHtml;
52+
})();
4053
//]]>
4154
</script></body>
4255
</html>

0 commit comments

Comments
 (0)