aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-17 01:35:04 +0900
committernsfisis <nsfisis@gmail.com>2023-03-17 01:35:04 +0900
commit0766039bd9e6b9f5e6334e84666f5be698d41fc3 (patch)
tree0f3a52fdbf56496850f903d64dcf7725fb0aedbe
parentee72f8780cf3681e4202cc3a6358fb4038db1ec8 (diff)
downloadblog.nsfisis.dev-0766039bd9e6b9f5e6334e84666f5be698d41fc3.tar.gz
blog.nsfisis.dev-0766039bd9e6b9f5e6334e84666f5be698d41fc3.tar.zst
blog.nsfisis.dev-0766039bd9e6b9f5e6334e84666f5be698d41fc3.zip
feat(nuldoc): implement syntax highlight
-rw-r--r--deno.lock2
-rw-r--r--import_map.json1
-rw-r--r--nuldoc-src/docbook/to_html.ts31
-rw-r--r--nuldoc-src/html.ts2
-rw-r--r--public/hl.css224
-rw-r--r--public/posts/2021-03-05/my-first-post/index.html2
-rw-r--r--public/posts/2021-03-30/phperkaigi-2021/index.html2
-rw-r--r--public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html40
-rw-r--r--public/posts/2021-10-02/python-unbound-local-error/index.html38
-rw-r--r--public/posts/2021-10-02/ruby-detect-running-implementation/index.html12
-rw-r--r--public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html108
-rw-r--r--public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html138
-rw-r--r--public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html28
-rw-r--r--public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html10
-rw-r--r--public/posts/2022-04-09/phperkaigi-2022-tokens/index.html258
-rw-r--r--public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html4
-rw-r--r--public/posts/2022-05-01/phperkaigi-2022/index.html2
-rw-r--r--public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html18
-rw-r--r--public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html2
-rw-r--r--public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html460
-rw-r--r--public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html70
-rw-r--r--public/posts/2022-10-28/setup-server-for-this-site/index.html42
-rw-r--r--public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html82
-rw-r--r--public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html154
-rw-r--r--public/posts/2023-03-10/rewrite-this-blog-generator/index.html2
-rw-r--r--static/hl.css224
26 files changed, 791 insertions, 1165 deletions
diff --git a/deno.lock b/deno.lock
index d9389f5..f9a666f 100644
--- a/deno.lock
+++ b/deno.lock
@@ -1,6 +1,8 @@
{
"version": "2",
"remote": {
+ "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/es/highlight.min.js": "69f14712953b725c3a81250737931446997607087dd8c02c89420b1661884516",
+ "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/es/languages/php.min.js": "4aee3f1a59241d30cd59090e066a7a6f781508b4bee6443ca64df97da28d26c2",
"https://deno.land/std@0.170.0/_util/asserts.ts": "d0844e9b62510f89ce1f9878b046f6a57bf88f208a10304aab50efcb48365272",
"https://deno.land/std@0.170.0/_util/os.ts": "8a33345f74990e627b9dfe2de9b040004b08ea5146c7c9e8fe9a29070d193934",
"https://deno.land/std@0.170.0/async/abortable.ts": "80b2ac399f142cc528f95a037a7d0e653296352d95c681e284533765961de409",
diff --git a/import_map.json b/import_map.json
index 0bbc3d3..904e8e8 100644
--- a/import_map.json
+++ b/import_map.json
@@ -1,5 +1,6 @@
{
"imports": {
+ "hljs/": "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/es/",
"std/": "https://deno.land/std@0.170.0/"
}
}
diff --git a/nuldoc-src/docbook/to_html.ts b/nuldoc-src/docbook/to_html.ts
index 64d3492..24be139 100644
--- a/nuldoc-src/docbook/to_html.ts
+++ b/nuldoc-src/docbook/to_html.ts
@@ -1,3 +1,5 @@
+import hljs from "hljs/highlight.min.js";
+import hljsPhp from "hljs/languages/php.min.js";
import { Document } from "./document.ts";
import { DocBookError } from "../errors.ts";
import {
@@ -31,6 +33,7 @@ export default function toHtml(doc: Document): Document {
transformNoteElement(doc);
setDefaultLangAttribute(doc);
traverseFootnotes(doc);
+ highlightPrograms(doc);
return doc;
}
@@ -277,3 +280,31 @@ function traverseFootnotes(doc: Document) {
n.children = [];
});
}
+
+function highlightPrograms(doc: Document) {
+ forEachChildRecursively(doc.root, (n) => {
+ if (n.kind !== "element" || n.name !== "pre") {
+ return;
+ }
+ const preClass = n.attributes.get("class") || "";
+ if (!preClass.includes("highlight")) {
+ return;
+ }
+ const codeElement = findFirstChildElement(n, "code");
+ if (!codeElement) {
+ return;
+ }
+ const language = n.attributes.get("language");
+ if (!language) {
+ return;
+ }
+ const sourceCode = codeElement.children[0].content;
+
+ const validLanguage = hljs.getLanguage(language) ? language : "plaintext";
+ const highlighted =
+ hljs.highlight(sourceCode, { language: validLanguage }).value;
+
+ codeElement.children[0].content = highlighted;
+ codeElement.attributes.set("class", "highlight");
+ });
+}
diff --git a/nuldoc-src/html.ts b/nuldoc-src/html.ts
index 5e573ad..70b5748 100644
--- a/nuldoc-src/html.ts
+++ b/nuldoc-src/html.ts
@@ -122,8 +122,8 @@ function nodeToHtmlText(n: Node, ctx: Context): string {
}
function textNodeToHtmlText(t: Text, ctx: Context): string {
+ if (ctx.isInPre) return t.content;
const s = encodeSpecialCharacters(t.content);
- if (ctx.isInPre) return s;
// TODO: 日本語で改行するときはスペースを入れない
return s
diff --git a/public/hl.css b/public/hl.css
index fabe9de..275239a 100644
--- a/public/hl.css
+++ b/public/hl.css
@@ -1,214 +1,10 @@
-/* ruby -rrouge -e 'puts Rouge::Themes::Github.render(scope: ".highlight")' */
-.highlight table td { padding: 5px; }
-.highlight table pre { margin: 0; }
-.highlight .cm {
- color: #999988;
- font-style: italic;
-}
-.highlight .cp {
- color: #999999;
- font-weight: bold;
-}
-.highlight .c1 {
- color: #999988;
- font-style: italic;
-}
-.highlight .cs {
- color: #999999;
- font-weight: bold;
- font-style: italic;
-}
-.highlight .c, .highlight .ch, .highlight .cd, .highlight .cpf {
- color: #999988;
- font-style: italic;
-}
-.highlight .err {
- color: #a61717;
- background-color: #e3d2d2;
-}
-.highlight .gd {
- color: #000000;
- background-color: #ffdddd;
-}
-.highlight .ge {
- color: #000000;
- font-style: italic;
-}
-.highlight .gr {
- color: #aa0000;
-}
-.highlight .gh {
- color: #999999;
-}
-.highlight .gi {
- color: #000000;
- background-color: #ddffdd;
-}
-.highlight .go {
- color: #888888;
-}
-.highlight .gp {
- color: #555555;
-}
-.highlight .gs {
- font-weight: bold;
-}
-.highlight .gu {
- color: #aaaaaa;
-}
-.highlight .gt {
- color: #aa0000;
-}
-.highlight .kc {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kd {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kn {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kp {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kr {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kt {
- color: #445588;
- font-weight: bold;
-}
-.highlight .k, .highlight .kv {
- color: #000000;
- font-weight: bold;
-}
-.highlight .mf {
- color: #009999;
-}
-.highlight .mh {
- color: #009999;
-}
-.highlight .il {
- color: #009999;
-}
-.highlight .mi {
- color: #009999;
-}
-.highlight .mo {
- color: #009999;
-}
-.highlight .m, .highlight .mb, .highlight .mx {
- color: #009999;
-}
-.highlight .sa {
- color: #000000;
- font-weight: bold;
-}
-.highlight .sb {
- color: #d14;
-}
-.highlight .sc {
- color: #d14;
-}
-.highlight .sd {
- color: #d14;
-}
-.highlight .s2 {
- color: #d14;
-}
-.highlight .se {
- color: #d14;
-}
-.highlight .sh {
- color: #d14;
-}
-.highlight .si {
- color: #d14;
-}
-.highlight .sx {
- color: #d14;
-}
-.highlight .sr {
- color: #009926;
-}
-.highlight .s1 {
- color: #d14;
-}
-.highlight .ss {
- color: #990073;
-}
-.highlight .s, .highlight .dl {
- color: #d14;
-}
-.highlight .na {
- color: #008080;
-}
-.highlight .bp {
- color: #999999;
-}
-.highlight .nb {
- color: #0086B3;
-}
-.highlight .nc {
- color: #445588;
- font-weight: bold;
-}
-.highlight .no {
- color: #008080;
-}
-.highlight .nd {
- color: #3c5d5d;
- font-weight: bold;
-}
-.highlight .ni {
- color: #800080;
-}
-.highlight .ne {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nf, .highlight .fm {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nl {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nn {
- color: #555555;
-}
-.highlight .nt {
- color: #000080;
-}
-.highlight .vc {
- color: #008080;
-}
-.highlight .vg {
- color: #008080;
-}
-.highlight .vi {
- color: #008080;
-}
-.highlight .nv, .highlight .vm {
- color: #008080;
-}
-.highlight .ow {
- color: #000000;
- font-weight: bold;
-}
-.highlight .o {
- color: #000000;
- font-weight: bold;
-}
-.highlight .w {
- color: #bbbbbb;
-}
-.highlight {
- background-color: #f8f8f8;
-} \ No newline at end of file
+pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
+ Theme: GitHub
+ Description: Light theme as seen on github.com
+ Author: github.com
+ Maintainer: @Hirse
+ Updated: 2021-05-15
+
+ Outdated base version: https://github.com/primer/github-syntax-light
+ Current colors taken from GitHub's CSS
+*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0} \ No newline at end of file
diff --git a/public/posts/2021-03-05/my-first-post/index.html b/public/posts/2021-03-05/my-first-post/index.html
index 37016b4..93df43a 100644
--- a/public/posts/2021-03-05/my-first-post/index.html
+++ b/public/posts/2021-03-05/my-first-post/index.html
@@ -9,7 +9,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>My First Post | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
diff --git a/public/posts/2021-03-30/phperkaigi-2021/index.html b/public/posts/2021-03-30/phperkaigi-2021/index.html
index 5da7c4a..aced3d6 100644
--- a/public/posts/2021-03-30/phperkaigi-2021/index.html
+++ b/public/posts/2021-03-30/phperkaigi-2021/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2021 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
diff --git a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html
index 10e4693..39ab3cd 100644
--- a/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html
+++ b/public/posts/2021-10-02/cpp-you-can-use-keywords-in-attributes/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【C++】 属性構文の属性名にはキーワードが使える | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -66,24 +66,24 @@
タイトル落ち。まずはこのコードを見て欲しい。
</p>
- <pre class="highlight" language="cpp" linenumbering="unnumbered"><code>#include &lt;iostream&gt;
+ <pre class="highlight" language="cpp" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;iostream&gt;</span></span>
-[[alignas]] [[alignof]] [[and]] [[and_eq]] [[asm]] [[auto]] [[bitand]]
-[[bitor]] [[bool]] [[break]] [[case]] [[catch]] [[char]] [[char16_t]]
-[[char32_t]] [[class]] [[compl]] [[const]] [[const_cast]] [[constexpr]]
-[[continue]] [[decltype]] [[default]] [[delete]] [[do]] [[double]]
-[[dynamic_cast]] [[else]] [[enum]] [[explicit]] [[export]] [[extern]] [[false]]
-[[final]] [[float]] [[for]] [[friend]] [[goto]] [[if]] [[inline]] [[int]]
-[[long]] [[mutable]] [[namespace]] [[new]] [[noexcept]] [[not]] [[not_eq]]
-[[nullptr]] [[operator]] [[or]] [[or_eq]] [[override]] [[private]]
-[[protected]] [[public]] [[register]] [[reinterpret_cast]] [[return]] [[short]]
-[[signed]] [[sizeof]] [[static]] [[static_assert]] [[static_cast]] [[struct]]
-[[switch]] [[template]] [[this]] [[thread_local]] [[throw]] [[true]] [[try]]
-[[typedef]] [[typeid]] [[typename]] [[union]] [[unsigned]]
-[[virtual]] [[void]] [[volatile]] [[wchar_t]] [[while]] [[xor]] [[xor_eq]]
-// [[using]]
-int main() {
-std::cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; std::endl;
+[[<span class="hljs-keyword">alignas</span>]] [[<span class="hljs-keyword">alignof</span>]] [[<span class="hljs-keyword">and</span>]] [[<span class="hljs-keyword">and_eq</span>]] [[<span class="hljs-keyword">asm</span>]] [[<span class="hljs-keyword">auto</span>]] [[<span class="hljs-keyword">bitand</span>]]
+[[<span class="hljs-keyword">bitor</span>]] [[<span class="hljs-type">bool</span>]] [[<span class="hljs-keyword">break</span>]] [[<span class="hljs-keyword">case</span>]] [[<span class="hljs-keyword">catch</span>]] [[<span class="hljs-type">char</span>]] [[<span class="hljs-type">char16_t</span>]]
+[[<span class="hljs-type">char32_t</span>]] [[<span class="hljs-keyword">class</span>]] [[<span class="hljs-keyword">compl</span>]] [[<span class="hljs-type">const</span>]] [[<span class="hljs-keyword">const_cast</span>]] [[<span class="hljs-keyword">constexpr</span>]]
+[[<span class="hljs-keyword">continue</span>]] [[<span class="hljs-keyword">decltype</span>]] [[<span class="hljs-keyword">default</span>]] [[<span class="hljs-keyword">delete</span>]] [[<span class="hljs-keyword">do</span>]] [[<span class="hljs-type">double</span>]]
+[[<span class="hljs-keyword">dynamic_cast</span>]] [[<span class="hljs-keyword">else</span>]] [[<span class="hljs-keyword">enum</span>]] [[<span class="hljs-keyword">explicit</span>]] [[<span class="hljs-keyword">export</span>]] [[<span class="hljs-keyword">extern</span>]] [[<span class="hljs-literal">false</span>]]
+[[<span class="hljs-keyword">final</span>]] [[<span class="hljs-type">float</span>]] [[<span class="hljs-keyword">for</span>]] [[<span class="hljs-keyword">friend</span>]] [[<span class="hljs-keyword">goto</span>]] [[<span class="hljs-keyword">if</span>]] [[<span class="hljs-keyword">inline</span>]] [[<span class="hljs-type">int</span>]]
+[[<span class="hljs-type">long</span>]] [[<span class="hljs-keyword">mutable</span>]] [[<span class="hljs-keyword">namespace</span>]] [[<span class="hljs-keyword">new</span>]] [[<span class="hljs-keyword">noexcept</span>]] [[<span class="hljs-keyword">not</span>]] [[<span class="hljs-keyword">not_eq</span>]]
+[[<span class="hljs-literal">nullptr</span>]] [[<span class="hljs-keyword">operator</span>]] [[<span class="hljs-keyword">or</span>]] [[<span class="hljs-keyword">or_eq</span>]] [[<span class="hljs-keyword">override</span>]] [[<span class="hljs-keyword">private</span>]]
+[[<span class="hljs-keyword">protected</span>]] [[<span class="hljs-keyword">public</span>]] [[<span class="hljs-keyword">register</span>]] [[<span class="hljs-keyword">reinterpret_cast</span>]] [[<span class="hljs-keyword">return</span>]] [[<span class="hljs-type">short</span>]]
+[[<span class="hljs-type">signed</span>]] [[<span class="hljs-keyword">sizeof</span>]] [[<span class="hljs-type">static</span>]] [[<span class="hljs-keyword">static_assert</span>]] [[<span class="hljs-keyword">static_cast</span>]] [[<span class="hljs-keyword">struct</span>]]
+[[<span class="hljs-keyword">switch</span>]] [[<span class="hljs-keyword">template</span>]] [[<span class="hljs-keyword">this</span>]] [[<span class="hljs-keyword">thread_local</span>]] [[<span class="hljs-keyword">throw</span>]] [[<span class="hljs-literal">true</span>]] [[<span class="hljs-keyword">try</span>]]
+[[<span class="hljs-keyword">typedef</span>]] [[<span class="hljs-keyword">typeid</span>]] [[<span class="hljs-keyword">typename</span>]] [[<span class="hljs-keyword">union</span>]] [[<span class="hljs-type">unsigned</span>]]
+[[<span class="hljs-keyword">virtual</span>]] [[<span class="hljs-type">void</span>]] [[<span class="hljs-keyword">volatile</span>]] [[<span class="hljs-type">wchar_t</span>]] [[<span class="hljs-keyword">while</span>]] [[<span class="hljs-keyword">xor</span>]] [[<span class="hljs-keyword">xor_eq</span>]]
+<span class="hljs-comment">// [[using]]</span>
+<span class="hljs-type">int</span> <span class="hljs-built_in">main</span>() {
+std::cout &lt;&lt; <span class="hljs-string">&quot;Hello, World!&quot;</span> &lt;&lt; std::endl;
}</code></pre>
<blockquote>
@@ -134,8 +134,8 @@ std::cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; std::endl;
上のコードでは<code>[[using]]</code>をコメントアウトしているが、これは<code>using</code>キーワードのみ属性構文の中で意味を持つからであり、このコメントアウトを外すとコンパイルに失敗する。
</p>
- <pre class="highlight" language="cpp" linenumbering="unnumbered"><code>// using の例
-[[using foo: attr1, attr2]] int x; // [[foo::attr1, foo::attr2]] の糖衣構文</code></pre>
+ <pre class="highlight" language="cpp" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment">// using の例</span>
+[[<span class="hljs-keyword">using</span> foo: attr1, attr2]] <span class="hljs-type">int</span> x; <span class="hljs-comment">// [[foo::attr1, foo::attr2]] の糖衣構文</span></code></pre>
<p>
C++17 の仕様も見てみる (正確には標準化前のドラフト)。
diff --git a/public/posts/2021-10-02/python-unbound-local-error/index.html b/public/posts/2021-10-02/python-unbound-local-error/index.html
index 4461af8..1631ccb 100644
--- a/public/posts/2021-10-02/python-unbound-local-error/index.html
+++ b/public/posts/2021-10-02/python-unbound-local-error/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【Python】 クロージャとUnboundLocalError: local variable &apos;x&apos; referenced before assignment | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -70,10 +70,10 @@
Python でクロージャを作ろうと、次のようなコードを書いた。
</p>
- <pre class="highlight" language="python" linenumbering="unnumbered"><code>def f():
-x = 0
-def g():
-x += 1
+ <pre class="highlight" language="python" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">def</span> <span class="hljs-title function_">f</span>():
+x = <span class="hljs-number">0</span>
+<span class="hljs-keyword">def</span> <span class="hljs-title function_">g</span>():
+x += <span class="hljs-number">1</span>
g()
f()</code></pre>
@@ -92,26 +92,26 @@ f()</code></pre>
local変数<code>x</code>が代入前に参照された、とある。これは、<code>f</code>の<code>x</code>を参照するのではなく、新しく別の変数を<code>g</code>内に作ってしまっているため。 前述のコードを宣言と代入を便宜上分けて書き直すと次のようになる。<code>var</code>を変数宣言のための構文として擬似的に利用している。
</p>
- <pre class="highlight" language="python" linenumbering="unnumbered"><code># 注: var は正しい Python の文法ではない。上記参照のこと
-def f():
-var x # f の local変数 &apos;x&apos; を宣言
-x = 0 # x に 0 を代入
-def g(): # f の内部関数 g を定義
-var x # g の local変数 &apos;x&apos; を宣言
-# たまたま f にも同じ名前の変数があるが、それとは別の変数
-x += 1 # x に 1 を加算 (x = x + 1 の糖衣構文)
-# 加算する前の値を参照しようとするが、まだ代入されていないためエラー
+ <pre class="highlight" language="python" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment"># 注: var は正しい Python の文法ではない。上記参照のこと</span>
+<span class="hljs-keyword">def</span> <span class="hljs-title function_">f</span>():
+var x <span class="hljs-comment"># f の local変数 &#x27;x&#x27; を宣言</span>
+x = <span class="hljs-number">0</span> <span class="hljs-comment"># x に 0 を代入</span>
+<span class="hljs-keyword">def</span> <span class="hljs-title function_">g</span>(): <span class="hljs-comment"># f の内部関数 g を定義</span>
+var x <span class="hljs-comment"># g の local変数 &#x27;x&#x27; を宣言</span>
+<span class="hljs-comment"># たまたま f にも同じ名前の変数があるが、それとは別の変数</span>
+x += <span class="hljs-number">1</span> <span class="hljs-comment"># x に 1 を加算 (x = x + 1 の糖衣構文)</span>
+<span class="hljs-comment"># 加算する前の値を参照しようとするが、まだ代入されていないためエラー</span>
g()</code></pre>
<p>
当初の意図を表現するには、次のように書けばよい。
</p>
- <pre class="highlight" language="python" linenumbering="unnumbered"><code>def f():
-x = 0
-def g():
-nonlocal x ## (*)
-x += 1
+ <pre class="highlight" language="python" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">def</span> <span class="hljs-title function_">f</span>():
+x = <span class="hljs-number">0</span>
+<span class="hljs-keyword">def</span> <span class="hljs-title function_">g</span>():
+<span class="hljs-keyword">nonlocal</span> x <span class="hljs-comment">## (*)</span>
+x += <span class="hljs-number">1</span>
g()</code></pre>
<p>
diff --git a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
index 06b5eb5..03bae40 100644
--- a/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
+++ b/public/posts/2021-10-02/ruby-detect-running-implementation/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【Ruby】 自身を実行している処理系の種類を判定する | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -75,10 +75,10 @@
上記ページの例から引用する:
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ ruby-1.9.1 -ve &apos;p RUBY_ENGINE&apos;
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ ruby-1.9.1 -ve &#x27;p RUBY_ENGINE&#x27;
ruby 1.9.1p0 (2009-03-04 revision 22762) [x86_64-linux]
&quot;ruby&quot;
-$ jruby -ve &apos;p RUBY_ENGINE&apos;
+$ jruby -ve &#x27;p RUBY_ENGINE&#x27;
jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
&quot;jruby&quot;</code></pre>
@@ -200,10 +200,10 @@ jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
<a href="https://github.com/mruby/mruby/blob/ed29d74bfd95362eaeb946fcf7e865d80346b62b/include/mruby/version.h#L32-L35">mruby 該当部分のソース</a>より引用:
</p>
- <pre class="highlight" language="c" linenumbering="unnumbered"><code>/*
+ <pre class="highlight" language="c" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment">/*
* Ruby engine.
-*/
-#define MRUBY_RUBY_ENGINE &quot;mruby&quot;</code></pre>
+*/</span>
+<span class="hljs-meta">#<span class="hljs-keyword">define</span> MRUBY_RUBY_ENGINE <span class="hljs-string">&quot;mruby&quot;</span></span></code></pre>
</div>
</article>
</main>
diff --git a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
index 49127f6..f66ae0b 100644
--- a/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
+++ b/public/posts/2021-10-02/ruby-then-keyword-and-case-in/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【Ruby】 then キーワードと case in | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -75,36 +75,36 @@
使われることは稀だが、Ruby では<code>then</code>がキーワードになっている。次のように使う:
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>if cond then
- puts &quot;Y&quot;
- else
- puts &quot;N&quot;
- end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">if</span> cond <span class="hljs-keyword">then</span>
+ puts <span class="hljs-string">&quot;Y&quot;</span>
+ <span class="hljs-keyword">else</span>
+ puts <span class="hljs-string">&quot;N&quot;</span>
+ <span class="hljs-keyword">end</span></code></pre>
<p>
このキーワードが現れうる場所はいくつかあり、<code>if</code>、<code>unless</code>、<code>rescue</code>、<code>case</code>構文がそれに当たる。 上記のように、何か条件を書いた後<code>then</code>を置き、式がそこで終了していることを示すマーカーとして機能する。
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code># Example:
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment"># Example:</span>
-if x then
+<span class="hljs-keyword">if</span> x <span class="hljs-keyword">then</span>
a
-end
+<span class="hljs-keyword">end</span>
-unless x then
+<span class="hljs-keyword">unless</span> x <span class="hljs-keyword">then</span>
a
-end
+<span class="hljs-keyword">end</span>
-begin
+<span class="hljs-keyword">begin</span>
a
-rescue then
+<span class="hljs-keyword">rescue</span> <span class="hljs-keyword">then</span>
b
-end
+<span class="hljs-keyword">end</span>
-case x
-when p then
+<span class="hljs-keyword">case</span> x
+<span class="hljs-keyword">when</span> p <span class="hljs-keyword">then</span>
a
-end</code></pre>
+<span class="hljs-keyword">end</span></code></pre>
</section>
<section id="section--_なぜ普段は書かなくてもよいのか">
@@ -113,17 +113,17 @@ end</code></pre>
普通 Ruby のコードで<code>then</code>を書くことはない。なぜか。次のコードを実行してみるとわかる。
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>if true puts &apos;Hello, World!&apos; end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">if</span> <span class="hljs-literal">true</span> puts <span class="hljs-string">&#x27;Hello, World!&#x27;</span> <span class="hljs-keyword">end</span></code></pre>
<p>
次のような構文エラーが出力される。
</p>
- <pre class="monospaced highlight"><code>20:1: syntax error, unexpected local variable or method, expecting `then&apos; or &apos;;&apos; or &apos;\n&apos;
-if true puts &apos;Hello, World!&apos; end
+ <pre class="monospaced highlight"><code>20:1: syntax error, unexpected local variable or method, expecting `then' or ';' or '\n'
+if true puts 'Hello, World!' end
^~~~
-20:1: syntax error, unexpected `end&apos;, expecting end-of-input
-...f true puts &apos;Hello, World!&apos; end</code></pre>
+20:1: syntax error, unexpected `end', expecting end-of-input
+...f true puts 'Hello, World!' end</code></pre>
<p>
二つ目のメッセージは無視して一つ目を読むと、<code>then</code>か<code>;</code>か改行が来るはずのところ変数だかメソッドだかが現れたことによりエラーとなっているようだ。
@@ -133,8 +133,8 @@ if true puts &apos;Hello, World!&apos; end
ポイントは改行が<code>then</code>(や<code>;</code>) の代わりとなることである。<code>true</code>の後に改行を入れてみる。
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>if true
-puts &apos;Hello, World!&apos; end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">if</span> <span class="hljs-literal">true</span>
+puts <span class="hljs-string">&#x27;Hello, World!&#x27;</span> <span class="hljs-keyword">end</span></code></pre>
<p>
無事 Hello, World! と出力されるようになった。
@@ -147,21 +147,21 @@ puts &apos;Hello, World!&apos; end</code></pre>
なぜ<code>then</code>や<code>;</code>や改行 (以下 「<code>then</code>等」) が必要なのだろうか。次の例を見てほしい:
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>if a b end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">if</span> a b <span class="hljs-keyword">end</span></code></pre>
<p>
<code>then</code>も<code>;</code>も改行もないのでエラーになるが、これは条件式がどこまで続いているのかわからないためだ。 この例は二通りに解釈できる。
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code># a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価
-if a then
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment"># a という変数かメソッドの評価結果が truthy なら b という変数かメソッドを評価</span>
+<span class="hljs-keyword">if</span> a <span class="hljs-keyword">then</span>
b
-end</code></pre>
+<span class="hljs-keyword">end</span></code></pre>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code># a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、
-# その結果が truthy なら何もしない
-if a(b) then
-end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment"># a というメソッドに b という変数かメソッドの評価結果を渡して呼び出し、</span>
+<span class="hljs-comment"># その結果が truthy なら何もしない</span>
+<span class="hljs-keyword">if</span> a(b) <span class="hljs-keyword">then</span>
+<span class="hljs-keyword">end</span></code></pre>
<p>
<code>then</code>等はこの曖昧性を排除するためにあり、条件式は<code>if</code>から<code>then</code>等までの間にある、ということを明確にする。 C系の<code>if</code>後に来る<code>(</code>/<code>)</code>や、Python の<code>:</code>、Rust/Go/Swift などの<code>{</code>も同じ役割を持つ。
@@ -182,7 +182,7 @@ end</code></pre>
<a href="https://github.com/ruby/ruby/blob/221ca0f8281d39f0dfdfe13b2448875384bbf735/parse.y#L3961-L3986">https://github.com/ruby/ruby/blob/221ca0f8281d39f0dfdfe13b2448875384bbf735/parse.y#L3961-L3986</a>
</p>
- <pre class="highlight" language="yacc" linenumbering="unnumbered"><code>p_case_body : keyword_in
+ <pre class="highlight" language="yacc" linenumbering="unnumbered"><code class="highlight">p_case_body : keyword_in
{
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p-&gt;command_start = FALSE;
@@ -213,7 +213,7 @@ end</code></pre>
簡略版:
</p>
- <pre class="highlight" language="yacc" linenumbering="unnumbered"><code>p_case_body : keyword_in p_top_expr then compstmt p_cases
+ <pre class="highlight" language="yacc" linenumbering="unnumbered"><code class="highlight">p_case_body : keyword_in p_top_expr then compstmt p_cases
;</code></pre>
<p>
@@ -224,36 +224,36 @@ end</code></pre>
これにより、<code>case</code>-<code>when</code>による従来の構文と同じように、<code>then</code>等をパターンの後ろに挿入すればよいことがわかった。つまり次の3通りのいずれかになる:
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>case x
-in 1 then a
-in 2 then b
-in 3 then c
-end
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">case</span> x
+<span class="hljs-keyword">in</span> <span class="hljs-number">1</span> <span class="hljs-keyword">then</span> a
+<span class="hljs-keyword">in</span> <span class="hljs-number">2</span> <span class="hljs-keyword">then</span> b
+<span class="hljs-keyword">in</span> <span class="hljs-number">3</span> <span class="hljs-keyword">then</span> c
+<span class="hljs-keyword">end</span>
-case x
-in 1
+<span class="hljs-keyword">case</span> x
+<span class="hljs-keyword">in</span> <span class="hljs-number">1</span>
a
-in 2
+<span class="hljs-keyword">in</span> <span class="hljs-number">2</span>
b
-in 3
+<span class="hljs-keyword">in</span> <span class="hljs-number">3</span>
c
-end
+<span class="hljs-keyword">end</span>
-case x
-in 1; a
-in 2; b
-in 3; c
-end</code></pre>
+<span class="hljs-keyword">case</span> x
+<span class="hljs-keyword">in</span> <span class="hljs-number">1</span>; a
+<span class="hljs-keyword">in</span> <span class="hljs-number">2</span>; b
+<span class="hljs-keyword">in</span> <span class="hljs-number">3</span>; c
+<span class="hljs-keyword">end</span></code></pre>
<p>
ところで、<code>p_top_expr</code>には<code>if</code>による guard clause が書けるので、その場合は<code>if</code>-<code>then</code>と似たような見た目になる。
</p>
- <pre class="highlight" language="ruby" linenumbering="unnumbered"><code>case x
-in 0 then a
-in n if n &lt; 0 then b
-in n then c
-end</code></pre>
+ <pre class="highlight" language="ruby" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">case</span> x
+<span class="hljs-keyword">in</span> <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> a
+<span class="hljs-keyword">in</span> n <span class="hljs-keyword">if</span> n &lt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> b
+<span class="hljs-keyword">in</span> n <span class="hljs-keyword">then</span> c
+<span class="hljs-keyword">end</span></code></pre>
</section>
<section id="section--_まとめ">
diff --git a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
index e86d724..bc40aaa 100644
--- a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
+++ b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>Rust のプリミティブ型はどこからやって来るか | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -65,26 +65,26 @@
Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。
</p>
- <pre class="highlight" language="rust" linenumbering="unnumbered"><code>#![allow(non_camel_case_types)]
-#![allow(dead_code)]
+ <pre class="highlight" language="rust" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">#![allow(non_camel_case_types)]</span>
+<span class="hljs-meta">#![allow(dead_code)]</span>
-struct bool;
-struct char;
-struct i8;
-struct i16;
-struct i32;
-struct i64;
-struct i128;
-struct isize;
-struct u8;
-struct u16;
-struct u32;
-struct u64;
-struct u128;
-struct usize;
-struct f32;
-struct f64;
-struct str;</code></pre>
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">bool</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">char</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">i8</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">i16</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">i32</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">i64</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">i128</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">isize</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">u8</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">u16</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">u32</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">u64</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">u128</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">usize</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">f32</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">f64</span>;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">str</span>;</code></pre>
<p>
では、普段単に<code>bool</code>と書いたとき、この<code>bool</code>は一体どこから来ているのか。rustc のソースを追ってみた。
@@ -119,20 +119,20 @@ struct str;</code></pre>
<code>rustc</code>はセルフホストされている (=<code>rustc</code>自身が Rust で書かれている) ので、<code>bool</code>や<code>char</code>などで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことに<code>i128</code>/<code>u128</code>というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使って<code>git grep</code>してみる。
</p>
- <pre class="monospaced highlight"><code>$ git grep &quot;\bi128\b&quot; | wc # i128
+ <pre class="monospaced highlight"><code>$ git grep "\bi128\b" | wc # i128
165 1069 15790
-$ git grep &quot;\bu128\b&quot; | wc # u128
+$ git grep "\bu128\b" | wc # u128
293 2127 26667
-$ git grep &quot;\bbool\b&quot; | wc # cf. bool の結果
+$ git grep "\bbool\b" | wc # cf. bool の結果
3563 23577 294659</code></pre>
<p>
165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。
</p>
- <pre class="monospaced highlight"><code>$ git grep &quot;\bi128\b&quot;
+ <pre class="monospaced highlight"><code>$ git grep "\bi128\b"
...
rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128));
...</code></pre>
@@ -141,36 +141,36 @@ rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128));
<code>rustc_resolve</code>というのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。
</p>
- <pre class="highlight" language="rust" linenumbering="unnumbered"><code>/// Interns the names of the primitive types.
-///
-/// All other types are defined somewhere and possibly imported, but the primitive ones need
-/// special handling, since they have no place of origin.
-struct PrimitiveTypeTable {
+ <pre class="highlight" language="rust" linenumbering="unnumbered"><code class="highlight"><span class="hljs-comment">/// Interns the names of the primitive types.</span>
+<span class="hljs-comment">///</span>
+<span class="hljs-comment">/// All other types are defined somewhere and possibly imported, but the primitive ones need</span>
+<span class="hljs-comment">/// special handling, since they have no place of origin.</span>
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">PrimitiveTypeTable</span> {
primitive_types: FxHashMap&lt;Symbol, PrimTy&gt;,
}
-impl PrimitiveTypeTable {
-fn new() -&gt; PrimitiveTypeTable {
-let mut table = FxHashMap::default();
+<span class="hljs-keyword">impl</span> <span class="hljs-title class_">PrimitiveTypeTable</span> {
+<span class="hljs-keyword">fn</span> <span class="hljs-title function_">new</span>() <span class="hljs-punctuation">-&gt;</span> PrimitiveTypeTable {
+<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut </span><span class="hljs-variable">table</span> = FxHashMap::<span class="hljs-title function_ invoke__">default</span>();
-table.insert(sym::bool, Bool);
-table.insert(sym::char, Char);
-table.insert(sym::f32, Float(FloatTy::F32));
-table.insert(sym::f64, Float(FloatTy::F64));
-table.insert(sym::isize, Int(IntTy::Isize));
-table.insert(sym::i8, Int(IntTy::I8));
-table.insert(sym::i16, Int(IntTy::I16));
-table.insert(sym::i32, Int(IntTy::I32));
-table.insert(sym::i64, Int(IntTy::I64));
-table.insert(sym::i128, Int(IntTy::I128));
-table.insert(sym::str, Str);
-table.insert(sym::usize, Uint(UintTy::Usize));
-table.insert(sym::u8, Uint(UintTy::U8));
-table.insert(sym::u16, Uint(UintTy::U16));
-table.insert(sym::u32, Uint(UintTy::U32));
-table.insert(sym::u64, Uint(UintTy::U64));
-table.insert(sym::u128, Uint(UintTy::U128));
-Self { primitive_types: table }
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">bool</span>, Bool);
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">char</span>, Char);
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">f32</span>, <span class="hljs-title function_ invoke__">Float</span>(FloatTy::F32));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">f64</span>, <span class="hljs-title function_ invoke__">Float</span>(FloatTy::F64));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">isize</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::Isize));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">i8</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::I8));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">i16</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::I16));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">i32</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::I32));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">i64</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::I64));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">i128</span>, <span class="hljs-title function_ invoke__">Int</span>(IntTy::I128));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">str</span>, Str);
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">usize</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::Usize));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">u8</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::U8));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">u16</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::U16));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">u32</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::U32));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">u64</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::U64));
+table.<span class="hljs-title function_ invoke__">insert</span>(sym::<span class="hljs-type">u128</span>, <span class="hljs-title function_ invoke__">Uint</span>(UintTy::U128));
+<span class="hljs-keyword">Self</span> { primitive_types: table }
}
}</code></pre>
@@ -188,26 +188,26 @@ Self { primitive_types: table }
とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。
</p>
- <pre class="highlight" language="rust" linenumbering="unnumbered"><code> /// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
-/// (略)
-fn resolve_ident_in_lexical_scope(
-&amp;mut self,
-mut ident: Ident,
+ <pre class="highlight" language="rust" linenumbering="unnumbered"><code class="highlight"> <span class="hljs-comment">/// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.</span>
+<span class="hljs-comment">/// (略)</span>
+<span class="hljs-keyword">fn</span> <span class="hljs-title function_">resolve_ident_in_lexical_scope</span>(
+&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>,
+<span class="hljs-keyword">mut</span> ident: Ident,
ns: Namespace,
-// (略)
-) -&gt; Option&lt;LexicalScopeBinding&lt;&apos;a&gt;&gt; {
-// (略)
+<span class="hljs-comment">// (略)</span>
+) <span class="hljs-punctuation">-&gt;</span> <span class="hljs-type">Option</span>&lt;LexicalScopeBinding&lt;<span class="hljs-symbol">&#x27;a</span>&gt;&gt; {
+<span class="hljs-comment">// (略)</span>
-if ns == TypeNS {
-if let Some(prim_ty) = self.primitive_type_table.primitive_types.get(&amp;ident.name) {
-let binding =
-(Res::PrimTy(*prim_ty), ty::Visibility::Public, DUMMY_SP, ExpnId::root())
-.to_name_binding(self.arenas);
-return Some(LexicalScopeBinding::Item(binding));
+<span class="hljs-keyword">if</span> ns == TypeNS {
+<span class="hljs-keyword">if</span> <span class="hljs-keyword">let</span> <span class="hljs-variable">Some</span>(prim_ty) = <span class="hljs-keyword">self</span>.primitive_type_table.primitive_types.<span class="hljs-title function_ invoke__">get</span>(&amp;ident.name) {
+<span class="hljs-keyword">let</span> <span class="hljs-variable">binding</span> =
+(Res::<span class="hljs-title function_ invoke__">PrimTy</span>(*prim_ty), ty::Visibility::Public, DUMMY_SP, ExpnId::<span class="hljs-title function_ invoke__">root</span>())
+.<span class="hljs-title function_ invoke__">to_name_binding</span>(<span class="hljs-keyword">self</span>.arenas);
+<span class="hljs-keyword">return</span> <span class="hljs-title function_ invoke__">Some</span>(LexicalScopeBinding::<span class="hljs-title function_ invoke__">Item</span>(binding));
}
}
-None
+<span class="hljs-literal">None</span>
}</code></pre>
<p>
@@ -226,12 +226,12 @@ None
動作がわかったところで、例として次のコードを考える。
</p>
- <pre class="highlight" language="rust" linenumbering="unnumbered"><code>#![allow(non_camel_case_types)]
+ <pre class="highlight" language="rust" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">#![allow(non_camel_case_types)]</span>
-struct bool;
+<span class="hljs-keyword">struct</span> <span class="hljs-title class_">bool</span>;
-fn main() {
-let _: bool = bool;
+<span class="hljs-keyword">fn</span> <span class="hljs-title function_">main</span>() {
+<span class="hljs-keyword">let</span> <span class="hljs-variable">_</span>: <span class="hljs-type">bool</span> = <span class="hljs-type">bool</span>;
}</code></pre>
<p>
diff --git a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
index 049afdc..f45df6b 100644
--- a/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
+++ b/public/posts/2021-10-02/vim-difference-between-autocmd-bufwrite-and-bufwritepre/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【Vim】 autocmd events の BufWrite/BufWritePre の違い | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -122,24 +122,24 @@
<a href="https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L85-L86">https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L85-L86</a>
</p>
- <pre class="highlight" language="c" linenumbering="unnumbered"><code> {&quot;BufAdd&quot;, EVENT_BUFADD},
-{&quot;BufCreate&quot;, EVENT_BUFADD},</code></pre>
+ <pre class="highlight" language="c" linenumbering="unnumbered"><code class="highlight"> {<span class="hljs-string">&quot;BufAdd&quot;</span>, EVENT_BUFADD},
+{<span class="hljs-string">&quot;BufCreate&quot;</span>, EVENT_BUFADD},</code></pre>
<p>
<a href="https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L95-L97">https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L95-L97</a>
</p>
- <pre class="highlight" language="c" linenumbering="unnumbered"><code> {&quot;BufRead&quot;, EVENT_BUFREADPOST},
-{&quot;BufReadCmd&quot;, EVENT_BUFREADCMD},
-{&quot;BufReadPost&quot;, EVENT_BUFREADPOST},</code></pre>
+ <pre class="highlight" language="c" linenumbering="unnumbered"><code class="highlight"> {<span class="hljs-string">&quot;BufRead&quot;</span>, EVENT_BUFREADPOST},
+{<span class="hljs-string">&quot;BufReadCmd&quot;</span>, EVENT_BUFREADCMD},
+{<span class="hljs-string">&quot;BufReadPost&quot;</span>, EVENT_BUFREADPOST},</code></pre>
<p>
<a href="https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L103-L105">https://github.com/vim/vim/blob/8e6be34338f13a6a625f19bcef82019c9adc65f2/src/autocmd.c#L103-L105</a>
</p>
- <pre class="highlight" language="c" linenumbering="unnumbered"><code> {&quot;BufWrite&quot;, EVENT_BUFWRITEPRE},
-{&quot;BufWritePost&quot;, EVENT_BUFWRITEPOST},
-{&quot;BufWritePre&quot;, EVENT_BUFWRITEPRE},</code></pre>
+ <pre class="highlight" language="c" linenumbering="unnumbered"><code class="highlight"> {<span class="hljs-string">&quot;BufWrite&quot;</span>, EVENT_BUFWRITEPRE},
+{<span class="hljs-string">&quot;BufWritePost&quot;</span>, EVENT_BUFWRITEPOST},
+{<span class="hljs-string">&quot;BufWritePre&quot;</span>, EVENT_BUFWRITEPRE},</code></pre>
</section>
<section id="section--_neovim_のソースコード">
@@ -152,11 +152,11 @@
<a href="https://github.com/neovim/neovim/blob/71d4f5851f068eeb432af34850dddda8cc1c71e3/src/nvim/auevents.lua#L119-L124">https://github.com/neovim/neovim/blob/71d4f5851f068eeb432af34850dddda8cc1c71e3/src/nvim/auevents.lua#L119-L124</a>
</p>
- <pre class="highlight" language="lua" linenumbering="unnumbered"><code> aliases = {
-BufCreate = &apos;BufAdd&apos;,
-BufRead = &apos;BufReadPost&apos;,
-BufWrite = &apos;BufWritePre&apos;,
-FileEncoding = &apos;EncodingChanged&apos;,
+ <pre class="highlight" language="lua" linenumbering="unnumbered"><code class="highlight"> aliases = {
+BufCreate = <span class="hljs-string">&#x27;BufAdd&#x27;</span>,
+BufRead = <span class="hljs-string">&#x27;BufReadPost&#x27;</span>,
+BufWrite = <span class="hljs-string">&#x27;BufWritePre&#x27;</span>,
+FileEncoding = <span class="hljs-string">&#x27;EncodingChanged&#x27;</span>,
},</code></pre>
<p>
diff --git a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
index 366912c..8dbea05 100644
--- a/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
+++ b/public/posts/2021-10-02/vim-swap-order-of-selected-lines/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>Vimで選択した行の順番を入れ替える | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -125,7 +125,7 @@
なお、<code>:g/^/m0</code>は全ての行を入れ替えるが、<code>:N,Mg/^/mN-1</code>とすることで N行目から M行目を処理範囲とするよう拡張できる。手でこれを入力するわけにはいかないので、次のようなコマンドを用意する。
</p>
- <pre class="highlight" language="vim" linenumbering="unnumbered"><code>command! -bar -range=%
+ <pre class="highlight" language="vim" linenumbering="unnumbered"><code class="highlight">command! -bar -range=%
\ Reverse
\ &lt;line1&gt;,&lt;line2&gt;g/^/m&lt;line1&gt;-1</code></pre>
@@ -160,7 +160,7 @@
前述した<code>:Reverse</code>コマンドの定義を少し変えて、次のようにする:
</p>
- <pre class="highlight" language="vim" linenumbering="unnumbered"><code>function! s:reverse_lines(from, to) abort
+ <pre class="highlight" language="vim" linenumbering="unnumbered"><code class="highlight">function! s:reverse_lines(from, to) abort
execute printf(&quot;%d,%dg/^/m%d&quot;, a:from, a:to, a:from - 1)
endfunction
@@ -217,7 +217,7 @@
</p>
</blockquote>
- <pre class="highlight" language="vim" linenumbering="unnumbered"><code>command! -bar -range=%
+ <pre class="highlight" language="vim" linenumbering="unnumbered"><code class="highlight">command! -bar -range=%
\ Reverse
\ keeppatterns &lt;line1&gt;,&lt;line2&gt;g/^/m&lt;line1&gt;-1</code></pre>
@@ -234,7 +234,7 @@
<section id="section--_コピペ用再掲">
<h2><a href="#section--_コピペ用再掲">コピペ用再掲</a></h2>
- <pre class="highlight" language="vim" linenumbering="unnumbered"><code>&quot; License: Public Domain
+ <pre class="highlight" language="vim" linenumbering="unnumbered"><code class="highlight">&quot; License: Public Domain
command! -bar -range=%
\ Reverse
diff --git a/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html b/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html
index 9ac3f90..25873b7 100644
--- a/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html
+++ b/public/posts/2022-04-09/phperkaigi-2022-tokens/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2022 トークン問題の解説 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -76,50 +76,50 @@
ソースコードはこちら。実行には PHP 8.1 以上が必要なので注意。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
- declare(strict_types=0O1);
+ <span class="hljs-keyword">declare</span>(strict_types=<span class="hljs-number">0O1</span>);
- namespace Dgcircus\PHPerKaigi\Y2022;
+ <span class="hljs-keyword">namespace</span> <span class="hljs-title class_">Dgcircus</span>\<span class="hljs-title class_">PHPerKaigi</span>\<span class="hljs-title class_">Y2022</span>;
- /**
- * @todo
+ <span class="hljs-comment">/**
+ * <span class="hljs-doctag">@todo</span>
* Run this program to acquire a PHPer token.
- */
+ */</span>
- https://creativecommons.org/publicdomain/zero/1.0/
+ https:<span class="hljs-comment">//creativecommons.org/publicdomain/zero/1.0/</span>
- \error_reporting(~+!&apos;We are hiring!&apos;);
+ \<span class="hljs-title function_ invoke__">error_reporting</span>(~+!<span class="hljs-string">&#x27;We are hiring!&#x27;</span>);
- $z = fn($f) =&gt; (fn($x) =&gt; $f(fn(...$xs) =&gt; $x($x)(...$xs)))(fn($x) =&gt; $f(fn(...$xs) =&gt; $x($x)(...$xs)));
- $id = \spl_object_id(...);
- $put = fn($c) =&gt; \printf(&apos;%c&apos;, $c);
- $mm = fn($p, $n) =&gt; new \ArrayObject(\array_fill(+!![], $n, $p));
+ <span class="hljs-variable">$z</span> = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$f</span></span>) =&gt;</span> (<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$x</span></span>) =&gt;</span> <span class="hljs-variable">$f</span>(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params">...<span class="hljs-variable">$xs</span></span>) =&gt;</span> <span class="hljs-variable">$x</span>(<span class="hljs-variable">$x</span>)(...<span class="hljs-variable">$xs</span>)))(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$x</span></span>) =&gt;</span> <span class="hljs-variable">$f</span>(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params">...<span class="hljs-variable">$xs</span></span>) =&gt;</span> <span class="hljs-variable">$x</span>(<span class="hljs-variable">$x</span>)(...<span class="hljs-variable">$xs</span>)));
+ <span class="hljs-variable">$id</span> = \<span class="hljs-title function_ invoke__">spl_object_id</span>(...);
+ <span class="hljs-variable">$put</span> = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$c</span></span>) =&gt;</span> \<span class="hljs-title function_ invoke__">printf</span>(<span class="hljs-string">&#x27;%c&#x27;</span>, <span class="hljs-variable">$c</span>);
+ <span class="hljs-variable">$mm</span> = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$p</span>, <span class="hljs-variable">$n</span></span>) =&gt;</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">\ArrayObject</span>(\<span class="hljs-title function_ invoke__">array_fill</span>(+!![], <span class="hljs-variable">$n</span>, <span class="hljs-variable">$p</span>));
- $👉 = fn($m, $p, $b, $e, $mp, $pc) =&gt; [++$mp, ++$pc];
- $👈 = fn($m, $p, $b, $e, $mp, $pc) =&gt; [--$mp, ++$pc];
- $👍 = fn($m, $p, $b, $e, $mp, $pc) =&gt; [$mp, ++$pc, ++$m[$mp]];
- $👎 = fn($m, $p, $b, $e, $mp, $pc) =&gt; [$mp, ++$pc, --$m[$mp]];
- $📝 = fn($m, $p, $b, $e, $mp, $pc) =&gt; [$mp, ++$pc, $put($m[$mp])];
- $🤡 = fn($m, $p, $b, $e, $mp, $pc) =&gt; match ($m[$mp]) {
- +!![] =&gt; [$mp, $z(fn($loop) =&gt; fn($pc, $n) =&gt; match ($id($p[$pc])) {
- $b =&gt; $loop(++$pc, ++$n),
- $e =&gt; $n === +!![] ? ++$pc : $loop(++$pc, --$n),
- default =&gt; $loop(++$pc, $n),
- })($pc, -![])],
- default =&gt; [$mp, ++$pc],
+ $👉 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> [++<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>];
+ $👈 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> [--<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>];
+ $👍 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> [<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>, ++<span class="hljs-variable">$m</span>[<span class="hljs-variable">$mp</span>]];
+ $👎 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> [<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>, --<span class="hljs-variable">$m</span>[<span class="hljs-variable">$mp</span>]];
+ $📝 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> [<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>, <span class="hljs-variable">$put</span>(<span class="hljs-variable">$m</span>[<span class="hljs-variable">$mp</span>])];
+ $🤡 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> <span class="hljs-keyword">match</span> (<span class="hljs-variable">$m</span>[<span class="hljs-variable">$mp</span>]) {
+ +!![] =&gt; [<span class="hljs-variable">$mp</span>, <span class="hljs-variable">$z</span>(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$loop</span></span>) =&gt;</span> <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$pc</span>, <span class="hljs-variable">$n</span></span>) =&gt;</span> <span class="hljs-keyword">match</span> (<span class="hljs-variable">$id</span>(<span class="hljs-variable">$p</span>[<span class="hljs-variable">$pc</span>])) {
+ <span class="hljs-variable">$b</span> =&gt; <span class="hljs-variable">$loop</span>(++<span class="hljs-variable">$pc</span>, ++<span class="hljs-variable">$n</span>),
+ <span class="hljs-variable">$e</span> =&gt; <span class="hljs-variable">$n</span> === +!![] ? ++<span class="hljs-variable">$pc</span> : <span class="hljs-variable">$loop</span>(++<span class="hljs-variable">$pc</span>, --<span class="hljs-variable">$n</span>),
+ <span class="hljs-keyword">default</span> =&gt; <span class="hljs-variable">$loop</span>(++<span class="hljs-variable">$pc</span>, <span class="hljs-variable">$n</span>),
+ })(<span class="hljs-variable">$pc</span>, -![])],
+ <span class="hljs-keyword">default</span> =&gt; [<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>],
};
- $🎪 = fn($m, $p, $b, $e, $mp, $pc) =&gt; match ($m[$mp]) {
- +!![] =&gt; [$mp, ++$pc],
- default =&gt; [$mp, $z(fn($loop) =&gt; fn($pc, $n) =&gt; match ($id($p[$pc])) {
- $e =&gt; $loop(--$pc, ++$n),
- $b =&gt; $n === +!![] ? $pc+![] : $loop(--$pc, --$n),
- default =&gt; $loop(--$pc, $n),
- })($pc, -![])],
+ $🎪 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span> <span class="hljs-keyword">match</span> (<span class="hljs-variable">$m</span>[<span class="hljs-variable">$mp</span>]) {
+ +!![] =&gt; [<span class="hljs-variable">$mp</span>, ++<span class="hljs-variable">$pc</span>],
+ <span class="hljs-keyword">default</span> =&gt; [<span class="hljs-variable">$mp</span>, <span class="hljs-variable">$z</span>(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$loop</span></span>) =&gt;</span> <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$pc</span>, <span class="hljs-variable">$n</span></span>) =&gt;</span> <span class="hljs-keyword">match</span> (<span class="hljs-variable">$id</span>(<span class="hljs-variable">$p</span>[<span class="hljs-variable">$pc</span>])) {
+ <span class="hljs-variable">$e</span> =&gt; <span class="hljs-variable">$loop</span>(--<span class="hljs-variable">$pc</span>, ++<span class="hljs-variable">$n</span>),
+ <span class="hljs-variable">$b</span> =&gt; <span class="hljs-variable">$n</span> === +!![] ? <span class="hljs-variable">$pc</span>+![] : <span class="hljs-variable">$loop</span>(--<span class="hljs-variable">$pc</span>, --<span class="hljs-variable">$n</span>),
+ <span class="hljs-keyword">default</span> =&gt; <span class="hljs-variable">$loop</span>(--<span class="hljs-variable">$pc</span>, <span class="hljs-variable">$n</span>),
+ })(<span class="hljs-variable">$pc</span>, -![])],
};
- $🐘 = fn($p) =&gt; $z(fn($loop) =&gt; fn($m, $p, $b, $e, $mp, $pc) =&gt;
- isset($p[$pc]) &amp;&amp; $loop($m, $p, $b, $e, ...($p[$pc]($m, $p, $b, $e, $mp, $pc)))
- )($mm(+!![], +(![].![])), $p, $id($🤡), $id($🎪), +!![], +!![]);
+ $🐘 = <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$p</span></span>) =&gt;</span> <span class="hljs-variable">$z</span>(<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$loop</span></span>) =&gt;</span> <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span></span>) =&gt;</span>
+ <span class="hljs-keyword">isset</span>(<span class="hljs-variable">$p</span>[<span class="hljs-variable">$pc</span>]) &amp;&amp; <span class="hljs-variable">$loop</span>(<span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, ...(<span class="hljs-variable">$p</span>[<span class="hljs-variable">$pc</span>](<span class="hljs-variable">$m</span>, <span class="hljs-variable">$p</span>, <span class="hljs-variable">$b</span>, <span class="hljs-variable">$e</span>, <span class="hljs-variable">$mp</span>, <span class="hljs-variable">$pc</span>)))
+ )(<span class="hljs-variable">$mm</span>(+!![], +(![].![])), <span class="hljs-variable">$p</span>, <span class="hljs-variable">$id</span>($🤡), <span class="hljs-variable">$id</span>($🎪), +!![], +!![]);
$🐘([
$👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍, $👍,
@@ -175,26 +175,26 @@
<pre class="monospaced highlight"><code>+ + + + + + + + + +
[
-&gt; + + +
-&gt; + + + + +
-&gt; + + + + + + + + + + + +
-&gt; + + + + + + + + + +
-&lt; &lt; &lt; &lt; -
+> + + +
+> + + + + +
+> + + + + + + + + + + + +
+> + + + + + + + + + +
+< < < < -
]
-&gt; + + + + + .
+> + + + + + .
- - .
-&gt; - - - .
-&gt; - - - .
+> - - - .
+> - - - .
- - .
- .
-&lt; .
-&gt; &gt; - - .
+< .
+> > - - .
+ + + + + + + .
-&lt; - - - - .
-&lt; .
-&gt; + + .
-&gt; - .
-&lt; .</code></pre>
+< - - - - .
+< .
+> + + .
+> - .
+< .</code></pre>
<p>
実行結果はこちら:<a href="https://ideone.com/22VWmb">https://ideone.com/22VWmb</a>
@@ -277,7 +277,7 @@
ソースコードのライセンスを示したこの部分だが、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>https://creativecommons.org/publicdomain/zero/1.0/</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">https:<span class="hljs-comment">//creativecommons.org/publicdomain/zero/1.0/</span></code></pre>
<p>
完全に合法な PHP のコードである。<code>https:</code>部分はラベル、<code>//</code>以降は行コメントになっている。
@@ -290,11 +290,11 @@
ソースコード中に、ほとんど数値リテラルが書かれていないことにお気づきだろうか。 PHP では、型変換を利用することで任意の整数を作り出すことができる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>assert(0 === +!![]);
-assert(1 === +![]);
-assert(2 === ![]+![]);
-assert(3 === ![]+![]+![]);
-assert(10 === +(![].+!![]));</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">0</span> === +!![]);
+<span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">1</span> === +![]);
+<span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">2</span> === ![]+![]);
+<span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">3</span> === ![]+![]+![]);
+<span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">10</span> === +(![].+!![]));</code></pre>
<p>
<code>[]</code>に<code>!</code>を適用すると<code>true</code>が返ってくる。それに<code>+</code>を適用すると、<code>bool</code>から<code>int</code>ヘの型変換が走り、<code>1</code>が生成される。<code>10</code>はさらにトリッキーだ。まず<code>1</code>と<code>0</code>を作り、<code>.</code>で文字列として結合する (<code>&apos;10&apos;</code>)。これに<code>+</code>を適用すると、<code>string</code>から<code>int</code>への型変換が走り、<code>10</code>が生まれる (コード量に頓着しないなら、<code>1</code>を 10 個足し合わせてももちろん 10 が作れる)。
@@ -335,11 +335,11 @@ assert(10 === +(![].+!![]));</code></pre>
ソースコードはこちら。実行には PHP 8.0 以上が必要なので注意。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
- /*********************************************************
+ <span class="hljs-comment">/*********************************************************
* This program displays a PHPer token. *
- * Guess &apos;N&apos;. *
+ * Guess &#x27;N&#x27;. *
* *
* Hints: *
* - N itself has no special meaning, e.g., 42, 8128, *
@@ -350,24 +350,24 @@ assert(10 === +(![].+!![]));</code></pre>
* *
* License: *
* https://creativecommons.org/publicdomain/zero/1.0/ *
- *********************************************************/
- const N = 0 /* Change it to your answer. */;
- assert(0 &lt;= N &amp;&amp; N &lt;= 0b11111_11111_11111_11111_11111);
+ *********************************************************/</span>
+ <span class="hljs-keyword">const</span> <span class="hljs-variable constant_">N</span> = <span class="hljs-number">0</span> <span class="hljs-comment">/* Change it to your answer. */</span>;
+ <span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">0</span> &lt;= N &amp;&amp; N &lt;= <span class="hljs-number">0b11111_11111_11111_11111_11111</span>);
- $token = [
- 0x14B499C,
- 0x0BE34CC, 0x01C9C69,
- 0x0ECA069, 0x01C2449, 0x0FDB166, 0x01C9C69,
- 0x01C1C66, 0x0FC1C47, 0x01C1C66,
- 0x10C5858, 0x1E4E3B8, 0x1A2F2F8,
+ <span class="hljs-variable">$token</span> = [
+ <span class="hljs-number">0x14B499C</span>,
+ <span class="hljs-number">0x0BE34CC</span>, <span class="hljs-number">0x01C9C69</span>,
+ <span class="hljs-number">0x0ECA069</span>, <span class="hljs-number">0x01C2449</span>, <span class="hljs-number">0x0FDB166</span>, <span class="hljs-number">0x01C9C69</span>,
+ <span class="hljs-number">0x01C1C66</span>, <span class="hljs-number">0x0FC1C47</span>, <span class="hljs-number">0x01C1C66</span>,
+ <span class="hljs-number">0x10C5858</span>, <span class="hljs-number">0x1E4E3B8</span>, <span class="hljs-number">0x1A2F2F8</span>,
];
- foreach ($token as $x) {
- $x = $x ^ N;
+ <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$token</span> <span class="hljs-keyword">as</span> <span class="hljs-variable">$x</span>) {
+ <span class="hljs-variable">$x</span> = <span class="hljs-variable">$x</span> ^ N;
- $x = sprintf(&apos;%025b&apos;, $x);
- $x = str_replace(search: [&apos;0&apos;, &apos;1&apos;], replace: [&apos; &apos;, &apos;#&apos;], subject: $x);
- $x = implode(&quot;\n&quot;, str_split($x, length: 5));
- echo &quot;{$x}\n\n&quot;;
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">sprintf</span>(<span class="hljs-string">&#x27;%025b&#x27;</span>, <span class="hljs-variable">$x</span>);
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">str_replace</span>(<span class="hljs-attr">search</span>: [<span class="hljs-string">&#x27;0&#x27;</span>, <span class="hljs-string">&#x27;1&#x27;</span>], <span class="hljs-attr">replace</span>: [<span class="hljs-string">&#x27; &#x27;</span>, <span class="hljs-string">&#x27;#&#x27;</span>], <span class="hljs-attr">subject</span>: <span class="hljs-variable">$x</span>);
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&quot;\n&quot;</span>, <span class="hljs-title function_ invoke__">str_split</span>(<span class="hljs-variable">$x</span>, <span class="hljs-attr">length</span>: <span class="hljs-number">5</span>));
+ <span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;<span class="hljs-subst">{$x}</span>\n\n&quot;</span>;
}</code></pre>
<p>
@@ -384,33 +384,33 @@ assert(10 === +(![].+!![]));</code></pre>
まずはソースコードを読んでいく。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$token = [
- // 略
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$token</span> = [
+ <span class="hljs-comment">// 略</span>
];</code></pre>
<p>
数値からなる<code>$token</code>があり、各要素をループしている。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code> $x = $x ^ N;</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"> <span class="hljs-variable">$x</span> = <span class="hljs-variable">$x</span> ^ N;</code></pre>
<p>
まずは排他的論理和 (xor) を取り、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code> $x = sprintf(&apos;%025b&apos;, $x);</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"> <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">sprintf</span>(<span class="hljs-string">&#x27;%025b&#x27;</span>, <span class="hljs-variable">$x</span>);</code></pre>
<p>
二進数に変換して、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code> $x = str_replace(search: [&apos;0&apos;, &apos;1&apos;], replace: [&apos; &apos;, &apos;#&apos;], subject: $x);</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"> <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">str_replace</span>(<span class="hljs-attr">search</span>: [<span class="hljs-string">&#x27;0&#x27;</span>, <span class="hljs-string">&#x27;1&#x27;</span>], <span class="hljs-attr">replace</span>: [<span class="hljs-string">&#x27; &#x27;</span>, <span class="hljs-string">&#x27;#&#x27;</span>], <span class="hljs-attr">subject</span>: <span class="hljs-variable">$x</span>);</code></pre>
<p>
0 を空白に、1 を<code>#</code>にし、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code> $x = implode(&quot;\n&quot;, str_split($x, length: 5));</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"> <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&quot;\n&quot;</span>, <span class="hljs-title function_ invoke__">str_split</span>(<span class="hljs-variable">$x</span>, <span class="hljs-attr">length</span>: <span class="hljs-number">5</span>));</code></pre>
<p>
5文字ごとに区切ったあと、改行で結合している。
@@ -464,49 +464,49 @@ assert(10 === +(![].+!![]));</code></pre>
<code>N</code>は高々
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>assert(0 &lt;= N &amp;&amp; N &lt;= 0b11111_11111_11111_11111_11111);</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-number">0</span> &lt;= N &amp;&amp; N &lt;= <span class="hljs-number">0b11111_11111_11111_11111_11111</span>);</code></pre>
<p>
なのでブルートフォースしてもよいが、ここではブルートフォースしない方法を紹介する。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
- $x = 0x14B499C;
+ <span class="hljs-variable">$x</span> = <span class="hljs-number">0x14B499C</span>;
- $x = $x ^ N;
+ <span class="hljs-variable">$x</span> = <span class="hljs-variable">$x</span> ^ N;
- $x = sprintf(&apos;%025b&apos;, $x);
- $x = str_replace(search: [&apos;0&apos;, &apos;1&apos;], replace: [&apos; &apos;, &apos;#&apos;], subject: $x);
- $x = implode(&quot;\n&quot;, str_split($x, length: 5));
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">sprintf</span>(<span class="hljs-string">&#x27;%025b&#x27;</span>, <span class="hljs-variable">$x</span>);
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">str_replace</span>(<span class="hljs-attr">search</span>: [<span class="hljs-string">&#x27;0&#x27;</span>, <span class="hljs-string">&#x27;1&#x27;</span>], <span class="hljs-attr">replace</span>: [<span class="hljs-string">&#x27; &#x27;</span>, <span class="hljs-string">&#x27;#&#x27;</span>], <span class="hljs-attr">subject</span>: <span class="hljs-variable">$x</span>);
+ <span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&quot;\n&quot;</span>, <span class="hljs-title function_ invoke__">str_split</span>(<span class="hljs-variable">$x</span>, <span class="hljs-attr">length</span>: <span class="hljs-number">5</span>));
- assert($x ===
- &quot; # # \n&quot; .
- &quot;#####\n&quot; .
- &quot; # # \n&quot; .
- &quot;#####\n&quot; .
- &quot; # # &quot;);</code></pre>
+ <span class="hljs-title function_ invoke__">assert</span>(<span class="hljs-variable">$x</span> ===
+ <span class="hljs-string">&quot; # # \n&quot;</span> .
+ <span class="hljs-string">&quot;#####\n&quot;</span> .
+ <span class="hljs-string">&quot; # # \n&quot;</span> .
+ <span class="hljs-string">&quot;#####\n&quot;</span> .
+ <span class="hljs-string">&quot; # # &quot;</span>);</code></pre>
<p>
この一連の変換に対する逆変換を考えると、次のようになる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
-$x =
-&quot; # # \n&quot; .
-&quot;#####\n&quot; .
-&quot; # # \n&quot; .
-&quot;#####\n&quot; .
-&quot; # # &quot;;
+<span class="hljs-variable">$x</span> =
+<span class="hljs-string">&quot; # # \n&quot;</span> .
+<span class="hljs-string">&quot;#####\n&quot;</span> .
+<span class="hljs-string">&quot; # # \n&quot;</span> .
+<span class="hljs-string">&quot;#####\n&quot;</span> .
+<span class="hljs-string">&quot; # # &quot;</span>;
-$x = implode(&apos;&apos;, explode(&quot;\n&quot;, $x));
-$x = str_replace(search: [&apos; &apos;, &apos;#&apos;], replace: [&apos;0&apos;, &apos;1&apos;], subject: $x);
-$x = bindec($x);
+<span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;&#x27;</span>, <span class="hljs-title function_ invoke__">explode</span>(<span class="hljs-string">&quot;\n&quot;</span>, <span class="hljs-variable">$x</span>));
+<span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">str_replace</span>(<span class="hljs-attr">search</span>: [<span class="hljs-string">&#x27; &#x27;</span>, <span class="hljs-string">&#x27;#&#x27;</span>], <span class="hljs-attr">replace</span>: [<span class="hljs-string">&#x27;0&#x27;</span>, <span class="hljs-string">&#x27;1&#x27;</span>], <span class="hljs-attr">subject</span>: <span class="hljs-variable">$x</span>);
+<span class="hljs-variable">$x</span> = <span class="hljs-title function_ invoke__">bindec</span>(<span class="hljs-variable">$x</span>);
-$n = $x ^ 0x14B499C;
+<span class="hljs-variable">$n</span> = <span class="hljs-variable">$x</span> ^ <span class="hljs-number">0x14B499C</span>;
-echo &quot;N = $n\n&quot;;</code></pre>
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;N = <span class="hljs-subst">$n</span>\n&quot;</span>;</code></pre>
<p>
これを実行すると、<code>N</code>が得られる。
@@ -520,41 +520,41 @@ echo &quot;N = $n\n&quot;;</code></pre>
ソースコードはこちら。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
- // License: https://creativecommons.org/publicdomain/zero/1.0/
- // This is a quine-like program to generate a PHPer token.
- // Execute it like this: php toquine.php | php | php | php | ...
+ <span class="hljs-comment">// License: https://creativecommons.org/publicdomain/zero/1.0/</span>
+ <span class="hljs-comment">// This is a quine-like program to generate a PHPer token.</span>
+ <span class="hljs-comment">// Execute it like this: php toquine.php | php | php | php | ...</span>
- $s = &lt;&lt;&lt;&apos;Q&apos;
- &lt;?cuc
- // Yvprafr: uggcf://perngvirpbzzbaf.bet/choyvpqbznva/mreb/1.0/
- // Guvf vf n dhvar-yvxr cebtenz gb trarengr n CUCre gbxra.
- // Rkrphgr vg yvxr guvf: cuc gbdhvar.cuc | cuc | cuc | cuc | ...
- %f$f = %f;
- $f = fge_ebg13($f); $kf = [
+ <span class="hljs-variable">$s</span> = &lt;&lt;&lt;<span class="hljs-string">&#x27;Q&#x27;</span>
+ <span class="hljs-meta">&lt;?</span>cuc
+ <span class="hljs-comment">// Yvprafr: uggcf://perngvirpbzzbaf.bet/choyvpqbznva/mreb/1.0/</span>
+ <span class="hljs-comment">// Guvf vf n dhvar-yvxr cebtenz gb trarengr n CUCre gbxra.</span>
+ <span class="hljs-comment">// Rkrphgr vg yvxr guvf: cuc gbdhvar.cuc | cuc | cuc | cuc | ...</span>
+ %f<span class="hljs-variable">$f</span> = %f;
+ <span class="hljs-variable">$f</span> = <span class="hljs-title function_ invoke__">fge_ebg13</span>(<span class="hljs-variable">$f</span>); <span class="hljs-variable">$kf</span> = [
%f,
];
- $g = ahyy.snyfr; sbe ($v = 0; $v &lt;= vagqvi(__YVAR__-035,6); ++$v) vs (!vffrg($kf[$v])) oernx; ryfr
- $g .= vzcybqr(&quot;\a&quot;, fge_fcyvg(fge_ercynpr([&apos;0&apos;,&apos;1&apos;], [&apos; &apos;,&apos;##&apos;], fcevags(pue(37) . &apos;025o&apos;, $kf[$v])), 012)) . &quot;\a\a&quot;;
- $jf = neenl_znc(sa($j) =&gt; vzcybqr(&apos;, &apos;, $j), neenl_puhax(neenl_znc(sa($k) =&gt; fcevags(&apos;0k&apos; . pue(37) . &apos;07K&apos;, $k), $kf), 10));
- cevags($f, $g, fge_ebg13(&quot;&lt;&lt;&lt;&apos;Q&apos;\a{$f}\aQ&quot;), vzcybqr(&quot;,\a&quot;, $jf));
+ <span class="hljs-variable">$g</span> = ahyy.snyfr; <span class="hljs-title function_ invoke__">sbe</span> (<span class="hljs-variable">$v</span> = <span class="hljs-number">0</span>; <span class="hljs-variable">$v</span> &lt;= <span class="hljs-title function_ invoke__">vagqvi</span>(__YVAR__-<span class="hljs-number">035</span>,<span class="hljs-number">6</span>); ++<span class="hljs-variable">$v</span>) <span class="hljs-title function_ invoke__">vs</span> (!<span class="hljs-title function_ invoke__">vffrg</span>(<span class="hljs-variable">$kf</span>[<span class="hljs-variable">$v</span>])) oernx; ryfr
+ <span class="hljs-variable">$g</span> .= <span class="hljs-title function_ invoke__">vzcybqr</span>(<span class="hljs-string">&quot;\a&quot;</span>, <span class="hljs-title function_ invoke__">fge_fcyvg</span>(<span class="hljs-title function_ invoke__">fge_ercynpr</span>([<span class="hljs-string">&#x27;0&#x27;</span>,<span class="hljs-string">&#x27;1&#x27;</span>], [<span class="hljs-string">&#x27; &#x27;</span>,<span class="hljs-string">&#x27;##&#x27;</span>], <span class="hljs-title function_ invoke__">fcevags</span>(<span class="hljs-title function_ invoke__">pue</span>(<span class="hljs-number">37</span>) . <span class="hljs-string">&#x27;025o&#x27;</span>, <span class="hljs-variable">$kf</span>[<span class="hljs-variable">$v</span>])), <span class="hljs-number">012</span>)) . <span class="hljs-string">&quot;\a\a&quot;</span>;
+ <span class="hljs-variable">$jf</span> = <span class="hljs-title function_ invoke__">neenl_znc</span>(<span class="hljs-title function_ invoke__">sa</span>(<span class="hljs-variable">$j</span>) =&gt; <span class="hljs-title function_ invoke__">vzcybqr</span>(<span class="hljs-string">&#x27;, &#x27;</span>, <span class="hljs-variable">$j</span>), <span class="hljs-title function_ invoke__">neenl_puhax</span>(<span class="hljs-title function_ invoke__">neenl_znc</span>(<span class="hljs-title function_ invoke__">sa</span>(<span class="hljs-variable">$k</span>) =&gt; <span class="hljs-title function_ invoke__">fcevags</span>(<span class="hljs-string">&#x27;0k&#x27;</span> . <span class="hljs-title function_ invoke__">pue</span>(<span class="hljs-number">37</span>) . <span class="hljs-string">&#x27;07K&#x27;</span>, <span class="hljs-variable">$k</span>), <span class="hljs-variable">$kf</span>), <span class="hljs-number">10</span>));
+ <span class="hljs-title function_ invoke__">cevags</span>(<span class="hljs-variable">$f</span>, <span class="hljs-variable">$g</span>, <span class="hljs-title function_ invoke__">fge_ebg13</span>(<span class="hljs-string">&quot;&lt;&lt;&lt;&#x27;Q&#x27;\a<span class="hljs-subst">{$f}</span>\aQ&quot;</span>), <span class="hljs-title function_ invoke__">vzcybqr</span>(<span class="hljs-string">&quot;,\a&quot;</span>, <span class="hljs-variable">$jf</span>));
Q;
- $s = str_rot13($s); $xs = [
- 0x0AFABEA, 0x1F294A7, 0x1F2109F, 0x1F294A7, 0x0002800, 0x1F2109F, 0x0117041, 0x1F294A7, 0x1FAD6B5, 0x1F295B7,
- 0x010FC21, 0x1FAD6B5, 0x1151151, 0x010FC21, 0x1F294A7, 0x1F295B7, 0x1FAD6B5, 0x1F294A7, 0x1F295B7, 0x1F8C63F,
- 0x1F8C631, 0x1FAD6B5, 0x17AD6BD, 0x17AD6BD, 0x1F8C63F, 0x1F295B7,
+ <span class="hljs-variable">$s</span> = <span class="hljs-title function_ invoke__">str_rot13</span>(<span class="hljs-variable">$s</span>); <span class="hljs-variable">$xs</span> = [
+ <span class="hljs-number">0x0AFABEA</span>, <span class="hljs-number">0x1F294A7</span>, <span class="hljs-number">0x1F2109F</span>, <span class="hljs-number">0x1F294A7</span>, <span class="hljs-number">0x0002800</span>, <span class="hljs-number">0x1F2109F</span>, <span class="hljs-number">0x0117041</span>, <span class="hljs-number">0x1F294A7</span>, <span class="hljs-number">0x1FAD6B5</span>, <span class="hljs-number">0x1F295B7</span>,
+ <span class="hljs-number">0x010FC21</span>, <span class="hljs-number">0x1FAD6B5</span>, <span class="hljs-number">0x1151151</span>, <span class="hljs-number">0x010FC21</span>, <span class="hljs-number">0x1F294A7</span>, <span class="hljs-number">0x1F295B7</span>, <span class="hljs-number">0x1FAD6B5</span>, <span class="hljs-number">0x1F294A7</span>, <span class="hljs-number">0x1F295B7</span>, <span class="hljs-number">0x1F8C63F</span>,
+ <span class="hljs-number">0x1F8C631</span>, <span class="hljs-number">0x1FAD6B5</span>, <span class="hljs-number">0x17AD6BD</span>, <span class="hljs-number">0x17AD6BD</span>, <span class="hljs-number">0x1F8C63F</span>, <span class="hljs-number">0x1F295B7</span>,
];
- $t = null.false; for ($i = 0; $i &lt;= intdiv(__LINE__-035,6); ++$i) if (!isset($xs[$i])) break; else
- $t .= implode(&quot;\n&quot;, str_split(str_replace([&apos;0&apos;,&apos;1&apos;], [&apos; &apos;,&apos;##&apos;], sprintf(chr(37) . &apos;025b&apos;, $xs[$i])), 012)) . &quot;\n\n&quot;;
- $ws = array_map(fn($w) =&gt; implode(&apos;, &apos;, $w), array_chunk(array_map(fn($x) =&gt; sprintf(&apos;0x&apos; . chr(37) . &apos;07X&apos;, $x), $xs), 10));
- printf($s, $t, str_rot13(&quot;&lt;&lt;&lt;&apos;D&apos;\n{$s}\nD&quot;), implode(&quot;,\n&quot;, $ws));</code></pre>
+ <span class="hljs-variable">$t</span> = <span class="hljs-literal">null</span>.<span class="hljs-literal">false</span>; <span class="hljs-keyword">for</span> (<span class="hljs-variable">$i</span> = <span class="hljs-number">0</span>; <span class="hljs-variable">$i</span> &lt;= <span class="hljs-title function_ invoke__">intdiv</span>(<span class="hljs-keyword">__LINE__</span>-<span class="hljs-number">035</span>,<span class="hljs-number">6</span>); ++<span class="hljs-variable">$i</span>) <span class="hljs-keyword">if</span> (!<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$xs</span>[<span class="hljs-variable">$i</span>])) <span class="hljs-keyword">break</span>; <span class="hljs-keyword">else</span>
+ <span class="hljs-variable">$t</span> .= <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&quot;\n&quot;</span>, <span class="hljs-title function_ invoke__">str_split</span>(<span class="hljs-title function_ invoke__">str_replace</span>([<span class="hljs-string">&#x27;0&#x27;</span>,<span class="hljs-string">&#x27;1&#x27;</span>], [<span class="hljs-string">&#x27; &#x27;</span>,<span class="hljs-string">&#x27;##&#x27;</span>], <span class="hljs-title function_ invoke__">sprintf</span>(<span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-number">37</span>) . <span class="hljs-string">&#x27;025b&#x27;</span>, <span class="hljs-variable">$xs</span>[<span class="hljs-variable">$i</span>])), <span class="hljs-number">012</span>)) . <span class="hljs-string">&quot;\n\n&quot;</span>;
+ <span class="hljs-variable">$ws</span> = <span class="hljs-title function_ invoke__">array_map</span>(fn(<span class="hljs-variable">$w</span>) =&gt; <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;, &#x27;</span>, <span class="hljs-variable">$w</span>), <span class="hljs-title function_ invoke__">array_chunk</span>(<span class="hljs-title function_ invoke__">array_map</span>(fn(<span class="hljs-variable">$x</span>) =&gt; <span class="hljs-title function_ invoke__">sprintf</span>(<span class="hljs-string">&#x27;0x&#x27;</span> . <span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-number">37</span>) . <span class="hljs-string">&#x27;07X&#x27;</span>, <span class="hljs-variable">$x</span>), <span class="hljs-variable">$xs</span>), <span class="hljs-number">10</span>));
+ <span class="hljs-title function_ invoke__">printf</span>(<span class="hljs-variable">$s</span>, <span class="hljs-variable">$t</span>, <span class="hljs-title function_ invoke__">str_rot13</span>(<span class="hljs-string">&quot;&lt;&lt;&lt;&#x27;D&#x27;\n<span class="hljs-subst">{$s}</span>\nD&quot;</span>), <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&quot;,\n&quot;</span>, <span class="hljs-variable">$ws</span>));</code></pre>
<p>
コメントにもあるとおり、次のようにして実行すれば答えがでてくる。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ php toquine.php | php | php | php | ...</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ php toquine.php | php | php | php | ...</code></pre>
<p>
実際にはもう少しパイプで繋げなければならない。
diff --git a/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html b/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html
index eb55d81..8ae0fa6 100644
--- a/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html
+++ b/public/posts/2022-04-24/term-banner-write-tool-showing-banner-in-terminal/index.html
@@ -9,7 +9,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>term-banner: ターミナルにバナーを表示するツールを書いた | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -53,7 +53,7 @@
こんなものを作った。
</p>
- <pre class="monospaced highlight"><code>$ term-banner &apos;Hello, World!&apos; &apos;こんにちは、&apos; &apos;世界!&apos;</code></pre>
+ <pre class="monospaced highlight"><code>$ term-banner 'Hello, World!' 'こんにちは、' '世界!'</code></pre>
<p>
image::https://raw.githubusercontent.com/nsfisis/term-banner/main/screenshot.png[term-banner のスクリーンショット]
diff --git a/public/posts/2022-05-01/phperkaigi-2022/index.html b/public/posts/2022-05-01/phperkaigi-2022/index.html
index ea9c581..a722db0 100644
--- a/public/posts/2022-05-01/phperkaigi-2022/index.html
+++ b/public/posts/2022-05-01/phperkaigi-2022/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2022 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
diff --git a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
index 851f76c..1e124bf 100644
--- a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
+++ b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHP カンファレンス沖縄で出題されたコードゴルフの問題を解いてみた | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -121,7 +121,7 @@
書いたものがこちら:
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>[&lt;?php $n=$argv[1];foreach([1e4,5e3,2e3,1e3,500,100,50,10,5,1]as$x)for(;$n&gt;=$x;$n-=$x)$r[]=$x;echo implode(&apos;, &apos;,$r??[]);?&gt;]</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">[<span class="hljs-meta">&lt;?php</span> <span class="hljs-variable">$n</span>=<span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>];<span class="hljs-keyword">foreach</span>([<span class="hljs-number">1e4</span>,<span class="hljs-number">5e3</span>,<span class="hljs-number">2e3</span>,<span class="hljs-number">1e3</span>,<span class="hljs-number">500</span>,<span class="hljs-number">100</span>,<span class="hljs-number">50</span>,<span class="hljs-number">10</span>,<span class="hljs-number">5</span>,<span class="hljs-number">1</span>]<span class="hljs-keyword">as</span><span class="hljs-variable">$x</span>)<span class="hljs-keyword">for</span>(;<span class="hljs-variable">$n</span>&gt;=<span class="hljs-variable">$x</span>;<span class="hljs-variable">$n</span>-=<span class="hljs-variable">$x</span>)<span class="hljs-variable">$r</span>[]=<span class="hljs-variable">$x</span>;<span class="hljs-keyword">echo</span> <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;, &#x27;</span>,<span class="hljs-variable">$r</span>??[]);<span class="hljs-meta">?&gt;</span>]</code></pre>
<p>
しめて 123 バイトとなった (末尾改行を含めずにカウント)。
@@ -131,15 +131,15 @@
こちらは改行とスペースを追加したバージョン:
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>[&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">[<span class="hljs-meta">&lt;?php</span>
- $n = $argv[1];
- foreach ([1e4, 5e3, 2e3, 1e3, 500, 100, 50, 10, 5, 1] as $x)
- for (; $n &gt;= $x; $n -= $x)
- $r[] = $x;
- echo implode(&apos;, &apos;, $r ?? []);
+ <span class="hljs-variable">$n</span> = <span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>];
+ <span class="hljs-keyword">foreach</span> ([<span class="hljs-number">1e4</span>, <span class="hljs-number">5e3</span>, <span class="hljs-number">2e3</span>, <span class="hljs-number">1e3</span>, <span class="hljs-number">500</span>, <span class="hljs-number">100</span>, <span class="hljs-number">50</span>, <span class="hljs-number">10</span>, <span class="hljs-number">5</span>, <span class="hljs-number">1</span>] <span class="hljs-keyword">as</span> <span class="hljs-variable">$x</span>)
+ <span class="hljs-keyword">for</span> (; <span class="hljs-variable">$n</span> &gt;= <span class="hljs-variable">$x</span>; <span class="hljs-variable">$n</span> -= <span class="hljs-variable">$x</span>)
+ <span class="hljs-variable">$r</span>[] = <span class="hljs-variable">$x</span>;
+ <span class="hljs-keyword">echo</span> <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;, &#x27;</span>, <span class="hljs-variable">$r</span> ?? []);
- ?&gt;]</code></pre>
+ <span class="hljs-meta">?&gt;</span>]</code></pre>
</section>
<section id="section--_使用したテクニック">
diff --git a/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html b/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html
index cc4f96e..a0e072b 100644
--- a/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html
+++ b/public/posts/2022-08-31/support-for-communty-is-employee-benefits/index.html
@@ -9,7 +9,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>弊社の PHP Foundation への寄付に寄せて | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
diff --git a/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html b/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html
index b450a07..7546291 100644
--- a/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html
+++ b/public/posts/2022-09-29/write-fizzbuzz-in-php-2-letters-per-line/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【PHP】 fizzbuzz を書く。1行あたり2文字で。 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -135,7 +135,7 @@
特に、C言語でこのような試みをおこなったことがあるかたならそう思うだろう。事実、Cでのこの制約はほとんど無意味に等しい。
</p>
- <pre class="highlight" language="c" linenumbering="unnumbered"><code>#\
+ <pre class="highlight" language="c" linenumbering="unnumbered"><code class="highlight">#\
i\
n\
c\
@@ -143,7 +143,7 @@ l\
u\
d\
e\
-&lt;\
+&amp;lt;\
s\
t\
d\
@@ -151,14 +151,14 @@ i\
o\
.\
h\
-&gt;\
-/*
-*/
+&amp;gt;\
+<span class="hljs-comment">/*
+*/</span>
i\
n\
t\
-/*
-*/
+<span class="hljs-comment">/*
+*/</span>
m\
a\
i\
@@ -170,30 +170,30 @@ r(
i\
n\
t\
-/*
-*/
+<span class="hljs-comment">/*
+*/</span>
i=
-1;
-i&lt;
-1\
-0\
-0;
+<span class="hljs-number">1</span>;
+i&amp;lt;
+<span class="hljs-number">1</span>\
+<span class="hljs-number">0</span>\
+<span class="hljs-number">0</span>;
i\
+\
+)
-if
+<span class="hljs-keyword">if</span>
(i
%\
-15
+<span class="hljs-number">15</span>
==
-0)
+<span class="hljs-number">0</span>)
p\
r\
i\
n\
t\
f(
-&quot;\
+<span class="hljs-string">&quot;\
F\
i\
z\
@@ -204,11 +204,11 @@ z\
z\
%\
c\
-&quot;,
-10
+&quot;</span>,
+<span class="hljs-number">10</span>
);
-/* あとは同じように普通のプログラムを変形するだけなので省略 */</code></pre>
+<span class="hljs-comment">/* あとは同じように普通のプログラムを変形するだけなので省略 */</span></code></pre>
<p>
バックスラッシュを使った行継続がトークンを区切らない、というのがポイントだ。
@@ -268,9 +268,9 @@ c\
また、2文字だと文字列がまともに書けないのも辛い。<code>&apos;&apos;</code>だけで 2文字使うので、「1文字の文字列リテラル」というものを書くことができない。PHP では文字列リテラル中に生の改行が書けるので
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$a
-=&apos;
-a&apos;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$a</span>
+=<span class="hljs-string">&#x27;
+a&#x27;</span>
;;</code></pre>
<p>
@@ -290,10 +290,10 @@ a&apos;
まずは普通に書くとしよう。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-for ($i = 1; $i &lt; 100; $i++) {
- echo (($i % 3 ? &apos;&apos; : &apos;Fizz&apos;) . ($i % 5 ? &apos;&apos; : &apos;Buzz&apos;) ?: $i) . &quot;\n&quot;;
+<span class="hljs-keyword">for</span> (<span class="hljs-variable">$i</span> = <span class="hljs-number">1</span>; <span class="hljs-variable">$i</span> &amp;lt; <span class="hljs-number">100</span>; <span class="hljs-variable">$i</span>++) {
+ <span class="hljs-keyword">echo</span> ((<span class="hljs-variable">$i</span> % <span class="hljs-number">3</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Fizz&#x27;</span>) . (<span class="hljs-variable">$i</span> % <span class="hljs-number">5</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Buzz&#x27;</span>) ?: <span class="hljs-variable">$i</span>) . <span class="hljs-string">&quot;\n&quot;</span>;
}</code></pre>
<p>
@@ -307,13 +307,13 @@ for ($i = 1; $i &lt; 100; $i++) {
<code>for</code>は、3文字もある長いキーワードである。こんなものは使えない。<code>array_</code>系の関数を使って、適当に置き換えるとしよう。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-$s = range(1, 100);
-array_walk(
- $s,
- fn($i) =&gt;
- printf((($i % 3 ? &apos;&apos; : &apos;Fizz&apos;) . ($i % 5 ? &apos;&apos; : &apos;Buzz&apos;) ?: $i) . &quot;\n&quot;),
+<span class="hljs-variable">$s</span> = <span class="hljs-title function_ invoke__">range</span>(<span class="hljs-number">1</span>, <span class="hljs-number">100</span>);
+<span class="hljs-title function_ invoke__">array_walk</span>(
+ <span class="hljs-variable">$s</span>,
+ fn(<span class="hljs-variable">$i</span>) =&amp;gt;
+ <span class="hljs-title function_ invoke__">printf</span>(((<span class="hljs-variable">$i</span> % <span class="hljs-number">3</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Fizz&#x27;</span>) . (<span class="hljs-variable">$i</span> % <span class="hljs-number">5</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Buzz&#x27;</span>) ?: <span class="hljs-variable">$i</span>) . <span class="hljs-string">&quot;\n&quot;</span>),
);</code></pre>
<p>
@@ -327,17 +327,17 @@ array_walk(
<code>range</code>、<code>array_walk</code>、<code>printf</code>は長すぎるのでどうにかせねばならない。ここで、PHP の可変関数を使う。可変関数とは、関数名が文字列として入った変数を経由して、関数を呼び出す機能である。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-$r = &apos;range&apos;;
-$w = &apos;array_walk&apos;;
-$p = &apos;printf&apos;;
+<span class="hljs-variable">$r</span> = <span class="hljs-string">&#x27;range&#x27;</span>;
+<span class="hljs-variable">$w</span> = <span class="hljs-string">&#x27;array_walk&#x27;</span>;
+<span class="hljs-variable">$p</span> = <span class="hljs-string">&#x27;printf&#x27;</span>;
-$s = $r(1, 100);
-$w(
- $s,
- fn($i) =&gt;
- $p((($i % 3 ? &apos;&apos; : &apos;Fizz&apos;) . ($i % 5 ? &apos;&apos; : &apos;Buzz&apos;) ?: $i) . &quot;\n&quot;),
+<span class="hljs-variable">$s</span> = <span class="hljs-variable">$r</span>(<span class="hljs-number">1</span>, <span class="hljs-number">100</span>);
+<span class="hljs-variable">$w</span>(
+ <span class="hljs-variable">$s</span>,
+ <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$i</span></span>) =&amp;<span class="hljs-title">gt</span></span>;
+ <span class="hljs-variable">$p</span>(((<span class="hljs-variable">$i</span> % <span class="hljs-number">3</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Fizz&#x27;</span>) . (<span class="hljs-variable">$i</span> % <span class="hljs-number">5</span> ? <span class="hljs-string">&#x27;&#x27;</span> : <span class="hljs-string">&#x27;Buzz&#x27;</span>) ?: <span class="hljs-variable">$i</span>) . <span class="hljs-string">&quot;\n&quot;</span>),
);</code></pre>
<p>
@@ -365,7 +365,7 @@ $w(
というルールがない場合、「未定義の定数が評価された場合、その定数の名前が値になる」という PHP 7.x までの仕様が利用できる。例えば、<code>Fizz</code>という文字列が欲しければ、次のようにする。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$f
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$f</span>
=F
.i
.z
@@ -376,13 +376,13 @@ $w(
こうして簡単に文字列を作れる。なお、この仕様は 7.x 時点でも警告を受けるので、<code>@</code>演算子を使って抑制してやるとよい。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$f
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$f</span>
=@
F.
@i
-.#
+.<span class="hljs-comment">#</span>
@z
-.#
+.<span class="hljs-comment">#</span>
@z
;;</code></pre>
@@ -401,66 +401,66 @@ F.
ずばり、文字列同士のビット演算を使う。PHP では、文字列同士でビット演算 (<code>&amp;</code>、<code>|</code>、<code>^</code>) をした場合、文字列の各バイトごとに指定したビット演算がなされ、それを結合したものが演算結果となる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$a = &quot;12345&quot;;
-$b = &quot;world&quot;;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$a</span> = <span class="hljs-string">&quot;12345&quot;</span>;
+<span class="hljs-variable">$b</span> = <span class="hljs-string">&quot;world&quot;</span>;
-// $a ^ $b は次のコードと同じ
-$result = &apos;&apos;;
-for ($i = 0; $i &lt; min(strlen($a), strlen($b)); $i++) {
-$result .= $a[$i] ^ $b[$i];
+<span class="hljs-comment">// $a ^ $b は次のコードと同じ</span>
+<span class="hljs-variable">$result</span> = <span class="hljs-string">&#x27;&#x27;</span>;
+<span class="hljs-keyword">for</span> (<span class="hljs-variable">$i</span> = <span class="hljs-number">0</span>; <span class="hljs-variable">$i</span> &amp;lt; <span class="hljs-title function_ invoke__">min</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$a</span>), <span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$b</span>)); <span class="hljs-variable">$i</span>++) {
+<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$a</span>[<span class="hljs-variable">$i</span>] ^ <span class="hljs-variable">$b</span>[<span class="hljs-variable">$i</span>];
}
-echo $result;
-// =&gt; F]AXQ</code></pre>
+<span class="hljs-keyword">echo</span> <span class="hljs-variable">$result</span>;
+<span class="hljs-comment">// =&amp;gt; F]AXQ</span></code></pre>
<p>
これを踏まえ、次のコードを見てみよう。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$x = &quot;x\nOm\n&quot;;
-$y = &quot;\nk!\no&quot;;
-$r = $x ^ $y;
-echo &quot;$r\n&quot;;</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$x</span> = <span class="hljs-string">&quot;x\nOm\n&quot;</span>;
+<span class="hljs-variable">$y</span> = <span class="hljs-string">&quot;\nk!\no&quot;</span>;
+<span class="hljs-variable">$r</span> = <span class="hljs-variable">$x</span> ^ <span class="hljs-variable">$y</span>;
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;<span class="hljs-subst">$r</span>\n&quot;</span>;</code></pre>
<p>
実行すると、<code>range</code>が表示される。さて、PHP では文字列リテラル中に生の改行を直接書いてもよいのだった (「主な障害」の節を参照のこと)。書きかえてみよう。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$x
-=&apos;x
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$x</span>
+=<span class="hljs-string">&#x27;x
Om
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
k!
-o&apos;
+o&#x27;</span>
;
-$r = $x ^ $y;
-echo &quot;$r\n&quot;;</code></pre>
+<span class="hljs-variable">$r</span> = <span class="hljs-variable">$x</span> ^ <span class="hljs-variable">$y</span>;
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;<span class="hljs-subst">$r</span>\n&quot;</span>;</code></pre>
<p>
さらに<code>#</code>を使って適当に調整すると、次のようになる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$x
-=#
-&apos;x
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;x
Om
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
k!
-o&apos;
-;#
-$r
-=#
-$x
-^#
-$y
-;#
+o&#x27;</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$r</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
-echo &quot;$r\n&quot;;</code></pre>
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;<span class="hljs-subst">$r</span>\n&quot;</span>;</code></pre>
<p>
1行あたり2文字で、<code>range</code>という文字列を生成することに成功した。他の必要な文字列にも、同様の処理をほどこす。
@@ -478,154 +478,154 @@ echo &quot;$r\n&quot;;</code></pre>
完成したものがこちら。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-$x
-=#
-&apos;i
-S&apos;
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;i
+S&#x27;</span>
;;
-$y
-=&apos;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
b!
-&apos;;
-$c
-=#
-$x
-^#
-$y
-;#
-$x
-=#
-&apos;x
+&#x27;</span>;
+<span class="hljs-variable">$c</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;x
Om
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
k!
-o&apos;
-;#
-$r
-=#
-$x
-^#
-$y
-;#
-$x
-=#
-&apos;k
+o&#x27;</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$r</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;k
Sk
~}
Ma
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
x!
s!
k!
-&apos;;
-$w
-=#
-$x
-^#
-$y
-;#
-$x
-=#
-&apos;z
+&#x27;</span>;
+<span class="hljs-variable">$w</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;z
Hd
-G&apos;
-;#
-$y
-=&apos;
+G&#x27;</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
x!
~!
-&apos;;
-$p
-=#
-$x
-^#
-$y
-;#
-$x
-=#
-&apos;L
+&#x27;</span>;
+<span class="hljs-variable">$p</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;L
[p
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
c!
-&apos;;
-$f
-=#
-$x
-^#
-$y
-;#
-$x
-=#
-&apos;H
+&#x27;</span>;
+<span class="hljs-variable">$f</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;H
[p
-&apos;;
-$y
-=&apos;
+&#x27;</span>;
+<span class="hljs-variable">$y</span>
+=<span class="hljs-string">&#x27;
_!
-&apos;;
-$b
-=#
-$x
-^#
-$y
-;#
-$b
-[1
+&#x27;</span>;
+<span class="hljs-variable">$b</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$x</span>
+^<span class="hljs-comment">#</span>
+<span class="hljs-variable">$y</span>
+;<span class="hljs-comment">#</span>
+<span class="hljs-variable">$b</span>
+[<span class="hljs-number">1</span>
]=
-$c
-(#
-13
-*9
+<span class="hljs-variable">$c</span>
+(<span class="hljs-comment">#</span>
+<span class="hljs-number">13</span>
+*<span class="hljs-number">9</span>
);
-$s
-=#
-$r
-(1
+<span class="hljs-variable">$s</span>
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$r</span>
+(<span class="hljs-number">1</span>
,(
-10
+<span class="hljs-number">10</span>
**
-2)
+<span class="hljs-number">2</span>)
);
-$w
-(#
-$s
-,#
-fn
-(#
-$i
-)#
-=&gt;
-$p
+<span class="hljs-variable">$w</span>
+(<span class="hljs-comment">#</span>
+<span class="hljs-variable">$s</span>
+,<span class="hljs-comment">#</span>
+<span class="hljs-function"><span class="hljs-keyword">fn</span>
+(<span class="hljs-params">#
+<span class="hljs-variable">$i</span>
+</span>)#
+=&amp;<span class="hljs-title">gt</span></span>;
+<span class="hljs-variable">$p</span>
((
-(#
-$i
-%3
-?#
-&apos;&apos;
-:#
-$f
+(<span class="hljs-comment">#</span>
+<span class="hljs-variable">$i</span>
+%<span class="hljs-number">3</span>
+?<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;&#x27;</span>
+:<span class="hljs-comment">#</span>
+<span class="hljs-variable">$f</span>
).
-(#
-$i
-%5
-?#
-&apos;&apos;
-:#
-$b
+(<span class="hljs-comment">#</span>
+<span class="hljs-variable">$i</span>
+%<span class="hljs-number">5</span>
+?<span class="hljs-comment">#</span>
+<span class="hljs-string">&#x27;&#x27;</span>
+:<span class="hljs-comment">#</span>
+<span class="hljs-variable">$b</span>
)?
-:#
-$i
-)#
-.&apos;
-&apos;)
+:<span class="hljs-comment">#</span>
+<span class="hljs-variable">$i</span>
+)<span class="hljs-comment">#</span>
+.<span class="hljs-string">&#x27;
+&#x27;</span>)
);</code></pre>
</section>
@@ -646,17 +646,17 @@ $i
PHP では、バッククォートを使ってシェルを呼び出せる。これは<code>shell_exec</code>関数と等価である。さて、PHP ではバックスラッシュによる行継続が使えないと書いたが、シェルでは使える (当然だが、呼び出されるシェルに依存する。Bash なら大丈夫だろう。知らんけど)。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-printf(`
+<span class="hljs-title function_ invoke__">printf</span>(`
e\
c\
h\
o\
\
-1\
-2\
-3\
+<span class="hljs-number">1</span>\
+<span class="hljs-number">2</span>\
+<span class="hljs-number">3</span>\
`);</code></pre>
<p>
@@ -685,34 +685,34 @@ o\
もうこれ以上は不可能だと思っていたのだが、この記事の執筆中に解決する方法を思いついたので載せておく。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">&amp;lt;?php
-$c = &apos;chr&apos;;
+<span class="hljs-variable">$c</span> = <span class="hljs-string">&#x27;chr&#x27;</span>;
${
-&apos;_
-&apos;}
-=#
-$c
-(#
-32
+<span class="hljs-string">&#x27;_
+&#x27;</span>}
+=<span class="hljs-comment">#</span>
+<span class="hljs-variable">$c</span>
+(<span class="hljs-comment">#</span>
+<span class="hljs-number">32</span>
).
-$c
-(#
-92
+<span class="hljs-variable">$c</span>
+(<span class="hljs-comment">#</span>
+<span class="hljs-number">92</span>
);
-printf(`
+<span class="hljs-title function_ invoke__">printf</span>(`
e\
c\
h\
o\
${
-&apos;_
-&apos;}
-1\
-2\
-3\
+<span class="hljs-string">&#x27;_
+&#x27;</span>}
+<span class="hljs-number">1</span>\
+<span class="hljs-number">2</span>\
+<span class="hljs-number">3</span>\
`);</code></pre>
<p>
@@ -720,8 +720,8 @@ ${
</p>
<pre class="monospaced highlight"><code>${
-&apos;_
-&apos;}</code></pre>
+'_
+'}</code></pre>
<p>
は変数で、中にはスペースとエスケープが入っている (<code>chr(32) . chr(92)</code>)。シェルに渡されている文字列は次のようになる。
@@ -749,8 +749,8 @@ o\
</p>
<pre class="monospaced highlight"><code>${
-&apos;_
-&apos;}</code></pre>
+'_
+'}</code></pre>
<p>
最新版で警告が出るというのも美しくないので、私としては本編の解法を推す。
diff --git a/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html b/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html
index d7f71aa..10ef763 100644
--- a/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html
+++ b/public/posts/2022-10-23/phperkaigi-2023-unused-token-quiz-1/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2023: ボツになったトークン問題 その 1 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -78,26 +78,26 @@
注意: これはボツ問なので、得られたトークンを PHPerKaigi で入力してもポイントにはならない。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
-$π = $argv[1] ?? null;
-if ($π === null) {
-exit(&apos;No input.&apos;);
+$π = <span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>] ?? <span class="hljs-literal">null</span>;
+<span class="hljs-keyword">if</span> ($π === <span class="hljs-literal">null</span>) {
+<span class="hljs-keyword">exit</span>(<span class="hljs-string">&#x27;No input.&#x27;</span>);
}
-$π = trim($π);
-if (!is_numeric($π)) {
-exit(&apos;Invalid input.&apos;);
+$π = <span class="hljs-title function_ invoke__">trim</span>($π);
+<span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">is_numeric</span>($π)) {
+<span class="hljs-keyword">exit</span>(<span class="hljs-string">&#x27;Invalid input.&#x27;</span>);
}
-$s = implode(array_map(chr(...), str_split($π, 2)));
+<span class="hljs-variable">$s</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-title function_ invoke__">array_map</span>(<span class="hljs-title function_ invoke__">chr</span>(...), <span class="hljs-title function_ invoke__">str_split</span>($π, <span class="hljs-number">2</span>)));
-preg_match(&apos;/(\x23.+?) /&apos;, $s, $m);
-$t = $m[1] ?? &apos;&apos;;
+<span class="hljs-title function_ invoke__">preg_match</span>(<span class="hljs-string">&#x27;/(\x23.+?) /&#x27;</span>, <span class="hljs-variable">$s</span>, <span class="hljs-variable">$m</span>);
+<span class="hljs-variable">$t</span> = <span class="hljs-variable">$m</span>[<span class="hljs-number">1</span>] ?? <span class="hljs-string">&#x27;&#x27;</span>;
-if (md5($t) === &apos;056e831a4146bf123e8ea16613303d2e&apos;) {
-echo &quot;Token: {$t}\n&quot;;
-} else {
-echo &quot;Failed.\n&quot;;
+<span class="hljs-keyword">if</span> (<span class="hljs-title function_ invoke__">md5</span>(<span class="hljs-variable">$t</span>) === <span class="hljs-string">&#x27;056e831a4146bf123e8ea16613303d2e&#x27;</span>) {
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Token: <span class="hljs-subst">{$t}</span>\n&quot;</span>;
+} <span class="hljs-keyword">else</span> {
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Failed.\n&quot;</span>;
}</code></pre>
</section>
@@ -107,14 +107,14 @@ echo &quot;Failed.\n&quot;;
ソースを見るとわかるとおり、<code>$argv[1]</code>を参照している。それを<code>$π</code>なる変数に代入しているので、円周率を渡してみる。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ php Q.php 3.14
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ php Q.php 3.14
Failed.</code></pre>
<p>
失敗してしまった。精度を上げてみる。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ php Q.php 3.1415
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ php Q.php 3.1415
Failed.</code></pre>
<p>
@@ -125,7 +125,7 @@ Failed.</code></pre>
最初にトークンが得られるのは、小数点以下 16 桁目まで入力したときで、こうなる。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ php Q.php 3.1415926535897932
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ php Q.php 3.1415926535897932
Token: #YO</code></pre>
<p>
@@ -139,20 +139,20 @@ Token: #YO</code></pre>
短いので頭から追っていく。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$π = $argv[1] ?? null;
- if ($π === null) {
- exit(&apos;No input.&apos;);
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">$π = <span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>] ?? <span class="hljs-literal">null</span>;
+ <span class="hljs-keyword">if</span> ($π === <span class="hljs-literal">null</span>) {
+ <span class="hljs-keyword">exit</span>(<span class="hljs-string">&#x27;No input.&#x27;</span>);
}
- $π = trim($π);
- if (!is_numeric($π)) {
- exit(&apos;Invalid input.&apos;);
+ $π = <span class="hljs-title function_ invoke__">trim</span>($π);
+ <span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">is_numeric</span>($π)) {
+ <span class="hljs-keyword">exit</span>(<span class="hljs-string">&#x27;Invalid input.&#x27;</span>);
}</code></pre>
<p>
入力のバリデーション部分。数値のみ受け付ける。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$s = implode(array_map(chr(...), str_split($π, 2)));</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-variable">$s</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-title function_ invoke__">array_map</span>(<span class="hljs-title function_ invoke__">chr</span>(...), <span class="hljs-title function_ invoke__">str_split</span>($π, <span class="hljs-number">2</span>)));</code></pre>
<p>
<code>$π</code>を 2 文字ごとに区切り (<code>str_split</code>)、数値を ASCII コードと見做して文字に変換 (<code>chr</code>) して結合 (<code>implode</code>) している。
@@ -162,13 +162,13 @@ Token: #YO</code></pre>
例えば、<code>$π</code>が<code>&apos;656667&apos;</code>だったとすると、<code>65</code>、<code>66</code>、<code>67</code>に対応した<code>&apos;A&apos;</code>、<code>&apos;B&apos;</code>、<code>&apos;C&apos;</code>へと変換され、<code>&apos;ABC&apos;</code>になる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>$π = &apos;656667&apos;;
-$s = implode(array_map(chr(...), str_split($π, 2)));
-echo $s;
-// =&gt; ABC</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">$π = <span class="hljs-string">&#x27;656667&#x27;</span>;
+<span class="hljs-variable">$s</span> = <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-title function_ invoke__">array_map</span>(<span class="hljs-title function_ invoke__">chr</span>(...), <span class="hljs-title function_ invoke__">str_split</span>($π, <span class="hljs-number">2</span>)));
+<span class="hljs-keyword">echo</span> <span class="hljs-variable">$s</span>;
+<span class="hljs-comment">// =&gt; ABC</span></code></pre>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>preg_match(&apos;/(\x23.+?) /&apos;, $s, $m);
-$t = $m[1] ?? &apos;&apos;;</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-title function_ invoke__">preg_match</span>(<span class="hljs-string">&#x27;/(\x23.+?) /&#x27;</span>, <span class="hljs-variable">$s</span>, <span class="hljs-variable">$m</span>);
+<span class="hljs-variable">$t</span> = <span class="hljs-variable">$m</span>[<span class="hljs-number">1</span>] ?? <span class="hljs-string">&#x27;&#x27;</span>;</code></pre>
<p>
正規表現でマッチングしている。<code>\x23</code>は<code>#</code>と同じであることに留意すると、この正規表現は「<code>#</code>から始まる 2 以上の長さ (含<code>#</code>) の文字列で、最初に現れるスペースまで」にマッチする。つまりこれは、PHPerKaigi におけるトークンである。
@@ -178,10 +178,10 @@ $t = $m[1] ?? &apos;&apos;;</code></pre>
なお、<code>#</code>を直接書いていないのは、<code>/#.+?) /</code>と書くと、<code>#.+?)</code>という意図せぬトークンが登録されてしまうからである。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>if (md5($t) === &apos;056e831a4146bf123e8ea16613303d2e&apos;) {
-echo &quot;Token: {$t}\n&quot;;
-} else {
-echo &quot;Failed.\n&quot;;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-keyword">if</span> (<span class="hljs-title function_ invoke__">md5</span>(<span class="hljs-variable">$t</span>) === <span class="hljs-string">&#x27;056e831a4146bf123e8ea16613303d2e&#x27;</span>) {
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Token: <span class="hljs-subst">{$t}</span>\n&quot;</span>;
+} <span class="hljs-keyword">else</span> {
+<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Failed.\n&quot;</span>;
}</code></pre>
<p>
diff --git a/public/posts/2022-10-28/setup-server-for-this-site/index.html b/public/posts/2022-10-28/setup-server-for-this-site/index.html
index e050bac..2f458ad 100644
--- a/public/posts/2022-10-28/setup-server-for-this-site/index.html
+++ b/public/posts/2022-10-28/setup-server-for-this-site/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>【備忘録】 このサイト用の VPS をセットアップしたときのメモ | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -83,7 +83,7 @@
ローカルマシンで鍵を生成する。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/teika.key
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/teika.key
$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/github2teika.key</code></pre>
<p>
@@ -97,7 +97,7 @@
<code>.ssh/config</code>に設定しておく。
</p>
- <pre class="highlight" language="ssh_config" linenumbering="unnumbered"><code>Host teika
+ <pre class="highlight" language="ssh_config" linenumbering="unnumbered"><code class="highlight">Host teika
HostName **********
User **********
Port **********
@@ -120,7 +120,7 @@
管理者ユーザで作業すると危ないので、メインで使うユーザを作成する。<code>sudo</code>グループに追加して<code>sudo</code>できるようにし、<code>su</code>で切り替え。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo adduser **********
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo adduser **********
$ sudo adduser ********** sudo
$ su **********
$ cd</code></pre>
@@ -128,12 +128,12 @@
<section id="section--_ホスト名を変える">
<h3><a href="#section--_ホスト名を変える">ホスト名を変える</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo hostname teika</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo hostname teika</code></pre>
</section>
<section id="section--_公開鍵を置く">
<h3><a href="#section--_公開鍵を置く">公開鍵を置く</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ mkdir ~/.ssh
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ vi ~/.ssh/authorized_keys</code></pre>
@@ -148,7 +148,7 @@
SSH の設定を変更し、少しでも安全にしておく。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
$ sudo vi /etc/ssh/sshd_config</code></pre>
<ul>
@@ -175,7 +175,7 @@
そして設定を反映。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo systemctl restart sshd
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo systemctl restart sshd
$ sudo systemctl status sshd</code></pre>
</section>
@@ -185,7 +185,7 @@ $ sudo systemctl status sshd</code></pre>
今の SSH セッションは閉じずに、ターミナルを別途開いて疎通確認する。セッションを閉じてしまうと、SSH の設定に不備があった場合に締め出しをくらう。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ ssh teika</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ ssh teika</code></pre>
</section>
<section id="section--_ポートの遮断">
@@ -194,7 +194,7 @@ $ sudo systemctl status sshd</code></pre>
デフォルトの 22 番を閉じ、設定したポートだけ空ける。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo ufw deny ssh
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo ufw deny ssh
$ sudo ufw allow *******
$ sudo ufw enable
$ sudo ufw reload
@@ -211,20 +211,20 @@ $ sudo systemctl status sshd</code></pre>
GitHub に置いてある private リポジトリをサーバから clone したいので、SSH 鍵を生成して置いておく。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/github.key
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ ssh-keygen -t ed25519 -b 521 -f ~/.ssh/github.key
$ cat ~/.ssh/github.key.pub</code></pre>
<p>
<a href="https://github.com/settings/ssh">GitHub の設定画面</a>から、この公開鍵を追加する。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ vi ~/.ssh/config</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ vi ~/.ssh/config</code></pre>
<p>
設定はこう。
</p>
- <pre class="highlight" language="ssh_config" linenumbering="unnumbered"><code>Host github.com
+ <pre class="highlight" language="ssh_config" linenumbering="unnumbered"><code class="highlight">Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github.key</code></pre>
@@ -233,12 +233,12 @@ IdentityFile ~/.ssh/github.key</code></pre>
最後に接続できるか確認しておく。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>ssh -T github.com</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">ssh -T github.com</code></pre>
</section>
<section id="section--_パッケージの更新">
<h3><a href="#section--_パッケージの更新">パッケージの更新</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo apt update
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo apt update
$ sudo apt upgrade
$ sudo apt update
$ sudo apt upgrade
@@ -257,12 +257,12 @@ IdentityFile ~/.ssh/github.key</code></pre>
<section id="section--_使うソフトウェアのインストール">
<h3><a href="#section--_使うソフトウェアのインストール">使うソフトウェアのインストール</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo apt install docker docker-compose git make</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo apt install docker docker-compose git make</code></pre>
</section>
<section id="section--_メインユーザが_docker_を使えるように">
<h3><a href="#section--_メインユーザが_docker_を使えるように">メインユーザが Docker を使えるように</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>sudo adduser ********** docker</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">sudo adduser ********** docker</code></pre>
</section>
<section id="section--_httphttps_を通す">
@@ -271,7 +271,7 @@ IdentityFile ~/.ssh/github.key</code></pre>
80 番と 443 番を空ける。
</p>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ sudo ufw allow 80/tcp
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ sudo ufw allow 80/tcp
$ sudo ufw allow 443/tcp
$ sudo ufw reload
$ sudo ufw status</code></pre>
@@ -279,7 +279,7 @@ IdentityFile ~/.ssh/github.key</code></pre>
<section id="section--_リポジトリのクローン">
<h3><a href="#section--_リポジトリのクローン">リポジトリのクローン</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ cd
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ cd
$ git clone git@github.com:nsfisis/nsfisis.dev.git
$ cd nsfisis.dev
$ git submodule update --init</code></pre>
@@ -287,13 +287,13 @@ IdentityFile ~/.ssh/github.key</code></pre>
<section id="section--_certbot_で証明書取得">
<h3><a href="#section--_certbot_で証明書取得">certbot で証明書取得</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ docker-compose up -d acme-challenge
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ docker-compose up -d acme-challenge
$ make setup</code></pre>
</section>
<section id="section--_サーバを稼動させる">
<h3><a href="#section--_サーバを稼動させる">サーバを稼動させる</a></h3>
- <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code>$ make serve</code></pre>
+ <pre class="highlight" language="shell-session" linenumbering="unnumbered"><code class="highlight">$ make serve</code></pre>
</section>
</section>
diff --git a/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html b/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html
index fd1a1d2..e78fdce 100644
--- a/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html
+++ b/public/posts/2022-11-19/phperkaigi-2023-unused-token-quiz-2/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2023: ボツになったトークン問題 その 2 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -82,17 +82,17 @@
注意: これはボツ問なので、得られたトークンを PHPerKaigi で入力してもポイントにはならない。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
</code></pre>
<p>
@@ -106,42 +106,42 @@
実行してみると、次のような出力が得られる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- #
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-comment">#</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
</code></pre>
<p>
1 行目を除き、先ほどのコードとほぼ同じものが出てきた。もう一度実行してみる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- #
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-comment">#</span>
W
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
-&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+<span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;​&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;​&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
</code></pre>
<p>
今度は 2 行目が書き換えられた。すべての行が変化するまで繰り返すと次のようになる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- #
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-comment">#</span>
W
E
L
@@ -168,8 +168,8 @@ W
Vim で開くと次のようになる (1 行目を抜粋)。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- &lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;&lt;200b&gt;&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=&apos;&lt;200b&gt;&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;&lt;200b&gt;&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-meta">&lt;?php</span> <span class="hljs-title function_ invoke__">printf</span>((<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$s</span>)?<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">trim</span>(<span class="hljs-variable">$s</span>,<span class="hljs-string">&quot;&lt;200b&gt;&quot;</span>):<span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>))(<span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;&lt;200b&gt;&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;&lt;200b&gt;&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>).<span class="hljs-string">&quot;\n&quot;</span>,<span class="hljs-string">&quot;\x27<span class="hljs-subst">$s</span>\x27&quot;</span>);<span class="hljs-meta">?&gt;</span>
</code></pre>
<p>
@@ -195,16 +195,16 @@ W
続いて、トークンへの変換ロジックを解析する。注目すべきはこの部分だ。以下、ゼロ幅スペースは Vim での表示に合わせて<code>&lt;200b&gt;</code>と記載する。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- fn($s)=&gt;chr(strlen($s)/3)
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-function"><span class="hljs-keyword">fn</span>(<span class="hljs-params"><span class="hljs-variable">$s</span></span>)=&gt;</span><span class="hljs-title function_ invoke__">chr</span>(<span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$s</span>)/<span class="hljs-number">3</span>)
</code></pre>
<p>
PHP の<code>strlen()</code>は文字列のバイト数を返す。1 行目の<code>$s</code>は以下の内容となっており、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>
- $s=&apos;&lt;200b&gt;&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;&lt;200b&gt;&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&apos;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">
+ <span class="hljs-variable">$s</span>=<span class="hljs-string">&#x27;&lt;200b&gt;&lt;?php printf((isset($s)?fn($s)=&gt;trim($s,&quot;&lt;200b&gt;&quot;):fn($s)=&gt;chr(strlen($s)/3))($s=%s).&quot;\n&quot;,&quot;\x27$s\x27&quot;);?&gt;&#x27;</span>
</code></pre>
<p>
diff --git a/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html b/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html
index ab47b2b..61d9880 100644
--- a/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html
+++ b/public/posts/2023-01-10/phperkaigi-2023-unused-token-quiz-3/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHPerKaigi 2023: ボツになったトークン問題 その 3 | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -92,24 +92,24 @@
注意: これはボツ問なので、得られたトークンを PHPerKaigi で入力してもポイントにはならない。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
-try {
- f(g() / __LINE__);
-} catch (Throwable $e) {
- while ($e = $e-&gt;getPrevious()) printf(&apos;%c&apos;, $e-&gt;getLine() + 23);
- echo &quot;\n&quot;;
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
+<span class="hljs-keyword">try</span> {
+ <span class="hljs-title function_ invoke__">f</span>(<span class="hljs-title function_ invoke__">g</span>() / <span class="hljs-keyword">__LINE__</span>);
+} <span class="hljs-keyword">catch</span> (<span class="hljs-built_in">Throwable</span> <span class="hljs-variable">$e</span>) {
+ <span class="hljs-keyword">while</span> (<span class="hljs-variable">$e</span> = <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getPrevious</span>()) <span class="hljs-title function_ invoke__">printf</span>(<span class="hljs-string">&#x27;%c&#x27;</span>, <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getLine</span>() + <span class="hljs-number">23</span>);
+ <span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;\n&quot;</span>;
}
-function f(int $i) {
- if ($i &lt; 0) f();
- try {
- match ($i) {
- 0 =&gt; 0 / 0,
+<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> <span class="hljs-variable">$i</span></span>) </span>{
+ <span class="hljs-keyword">if</span> (<span class="hljs-variable">$i</span> &lt; <span class="hljs-number">0</span>) <span class="hljs-title function_ invoke__">f</span>();
+ <span class="hljs-keyword">try</span> {
+ <span class="hljs-keyword">match</span> (<span class="hljs-variable">$i</span>) {
+ <span class="hljs-number">0</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 15, 36 =&gt; 0 / 0,
- 14 =&gt; 0 / 0,
- 37 =&gt; 0 / 0,
+ <span class="hljs-number">15</span>, <span class="hljs-number">36</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">14</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">37</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
@@ -120,16 +120,16 @@ function f(int $i) {
- 6 =&gt; 0 / 0,
+ <span class="hljs-number">6</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 5 =&gt; 0 / 0,
+ <span class="hljs-number">5</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 22 =&gt; 0 / 0,
+ <span class="hljs-number">22</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 34, 35 =&gt; 0 / 0,
+ <span class="hljs-number">34</span>, <span class="hljs-number">35</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
@@ -138,10 +138,10 @@ function f(int $i) {
- 25 =&gt; 0 / 0,
- 17, 21 =&gt; 0 / 0,
+ <span class="hljs-number">25</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">17</span>, <span class="hljs-number">21</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 24, 32 =&gt; 0 / 0,
+ <span class="hljs-number">24</span>, <span class="hljs-number">32</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
@@ -149,12 +149,12 @@ function f(int $i) {
- 33 =&gt; 0 / 0,
+ <span class="hljs-number">33</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 16 =&gt; 0 / 0,
+ <span class="hljs-number">16</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 18 =&gt; 0 / 0,
+ <span class="hljs-number">18</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
@@ -163,35 +163,35 @@ function f(int $i) {
- 7 =&gt; 0 / 0,
+ <span class="hljs-number">7</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 2 =&gt; 0 / 0,
- 1, 20 =&gt; 0 / 0,
- 10, 28 =&gt; 0 / 0,
- 8, 12, 26 =&gt; 0 / 0,
- 4, 9, 13 =&gt; 0 / 0,
+ <span class="hljs-number">2</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">1</span>, <span class="hljs-number">20</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">10</span>, <span class="hljs-number">28</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">8</span>, <span class="hljs-number">12</span>, <span class="hljs-number">26</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">4</span>, <span class="hljs-number">9</span>, <span class="hljs-number">13</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 31 =&gt; 0 / 0,
+ <span class="hljs-number">31</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 29 =&gt; 0 / 0,
+ <span class="hljs-number">29</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 11 =&gt; 0 / 0,
+ <span class="hljs-number">11</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 3, 19, 23 =&gt; 0 / 0,
+ <span class="hljs-number">3</span>, <span class="hljs-number">19</span>, <span class="hljs-number">23</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 27 =&gt; 0 / 0,
+ <span class="hljs-number">27</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- 30 =&gt; 0 / 0,
+ <span class="hljs-number">30</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
};
- } finally {
- f($i - 1);
+ } <span class="hljs-keyword">finally</span> {
+ <span class="hljs-title function_ invoke__">f</span>(<span class="hljs-variable">$i</span> - <span class="hljs-number">1</span>);
}
}
@@ -201,8 +201,8 @@ function f(int $i) {
-function g() {
- return __LINE__;
+<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">g</span>(<span class="hljs-params"></span>) </span>{
+ <span class="hljs-keyword">return</span> <span class="hljs-keyword">__LINE__</span>;
}</code></pre>
<p>
@@ -247,19 +247,19 @@ function g() {
このうち 1つ目のケースは、<code>finally</code>節の中でエラーを投げると PHP 処理系が勝手に<code>$previous</code>を設定してくれる。
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
-try {
- try {
- throw new Exception(&quot;Error 1&quot;);
- } finally {
- throw new Exception(&quot;Error 2&quot;);
+<span class="hljs-keyword">try</span> {
+ <span class="hljs-keyword">try</span> {
+ <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Exception</span>(<span class="hljs-string">&quot;Error 1&quot;</span>);
+ } <span class="hljs-keyword">finally</span> {
+ <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Exception</span>(<span class="hljs-string">&quot;Error 2&quot;</span>);
}
-} catch (Exception $e) {
- echo $e-&gt;getMessage() . PHP_EOL;
- // =&gt; Error 2
- echo $e-&gt;getPrevious()-&gt;getMessage() . PHP_EOL;
- // =&gt; Error 1
+} <span class="hljs-keyword">catch</span> (<span class="hljs-built_in">Exception</span> <span class="hljs-variable">$e</span>) {
+ <span class="hljs-keyword">echo</span> <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getMessage</span>() . PHP_EOL;
+ <span class="hljs-comment">// =&gt; Error 2</span>
+ <span class="hljs-keyword">echo</span> <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getPrevious</span>()-&gt;<span class="hljs-title function_ invoke__">getMessage</span>() . PHP_EOL;
+ <span class="hljs-comment">// =&gt; Error 1</span>
}</code></pre>
<p>
@@ -273,14 +273,14 @@ try {
出力部をコメントや改行を追加して再掲する:
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
-try {
- f(g() / __LINE__);
-} catch (Throwable $e) {
- while ($e = $e-&gt;getPrevious()) {
- printf(&apos;%c&apos;, $e-&gt;getLine() + 23);
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
+<span class="hljs-keyword">try</span> {
+ <span class="hljs-title function_ invoke__">f</span>(<span class="hljs-title function_ invoke__">g</span>() / <span class="hljs-keyword">__LINE__</span>);
+} <span class="hljs-keyword">catch</span> (<span class="hljs-built_in">Throwable</span> <span class="hljs-variable">$e</span>) {
+ <span class="hljs-keyword">while</span> (<span class="hljs-variable">$e</span> = <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getPrevious</span>()) {
+ <span class="hljs-title function_ invoke__">printf</span>(<span class="hljs-string">&#x27;%c&#x27;</span>, <span class="hljs-variable">$e</span>-&gt;<span class="hljs-title function_ invoke__">getLine</span>() + <span class="hljs-number">23</span>);
}
- echo &quot;\n&quot;;
+ <span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;\n&quot;</span>;
}</code></pre>
<p>
@@ -291,7 +291,7 @@ try {
フォーマット指定子<code>%c</code>は、整数を ASCII コード<span></span>と見做して印字する。トークン<code>#base64_decode(&apos;SGVsbG8sIFdvcmxkIQ==&apos;)</code>の<code>b</code>であれば、ASCII コード<code>98</code>なので、75 行目で発生したエラー、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>1, 20 =&gt; 0 / 0,</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-number">1</span>, <span class="hljs-number">20</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,</code></pre>
<p>
によって表現されている。エラーを起こす方法はいろいろと考えられるが、今回はゼロ除算を使った。
@@ -308,24 +308,24 @@ try {
<code>f()</code>の定義を再掲する (エラーオブジェクトの行数を利用しているので、一部分だけ抜き出すと値が変わることに注意):
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>function f(int $i) {
- if ($i &lt; 0) f();
- try {
- match ($i) {
- 0 =&gt; 0 / 0, // 12 行目
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">f</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> <span class="hljs-variable">$i</span></span>) </span>{
+ <span class="hljs-keyword">if</span> (<span class="hljs-variable">$i</span> &lt; <span class="hljs-number">0</span>) <span class="hljs-title function_ invoke__">f</span>();
+ <span class="hljs-keyword">try</span> {
+ <span class="hljs-keyword">match</span> (<span class="hljs-variable">$i</span>) {
+ <span class="hljs-number">0</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>, <span class="hljs-comment">// 12 行目</span>
- 15, 36 =&gt; 0 / 0,
- 14 =&gt; 0 / 0,
- 37 =&gt; 0 / 0,
+ <span class="hljs-number">15</span>, <span class="hljs-number">36</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">14</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
+ <span class="hljs-number">37</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>,
- // (略)
+ <span class="hljs-comment">// (略)</span>
- 30 =&gt; 0 / 0, // 97 行目
+ <span class="hljs-number">30</span> =&gt; <span class="hljs-number">0</span> / <span class="hljs-number">0</span>, <span class="hljs-comment">// 97 行目</span>
};
- } finally {
- f($i - 1);
+ } <span class="hljs-keyword">finally</span> {
+ <span class="hljs-title function_ invoke__">f</span>(<span class="hljs-variable">$i</span> - <span class="hljs-number">1</span>);
}
}</code></pre>
@@ -333,12 +333,12 @@ try {
前述のように、<code>finally</code>節でエラーを投げると PHP 処理系が<code>$previous</code>を設定する。ここでは、エラーを繋げるために<code>f()</code>を再帰呼び出ししている。最初に<code>f()</code>を呼び出している箇所を確認すると、
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>&lt;?php
-try {
- f(g() / __LINE__); // 3 行目</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-meta">&lt;?php</span>
+<span class="hljs-keyword">try</span> {
+ <span class="hljs-title function_ invoke__">f</span>(<span class="hljs-title function_ invoke__">g</span>() / <span class="hljs-keyword">__LINE__</span>); <span class="hljs-comment">// 3 行目</span></code></pre>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>function g() {
- return __LINE__; // 111 行目
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">g</span>(<span class="hljs-params"></span>) </span>{
+ <span class="hljs-keyword">return</span> <span class="hljs-keyword">__LINE__</span>; <span class="hljs-comment">// 111 行目</span>
}</code></pre>
<p>
diff --git a/public/posts/2023-03-10/rewrite-this-blog-generator/index.html b/public/posts/2023-03-10/rewrite-this-blog-generator/index.html
index 0d05ca5..855203b 100644
--- a/public/posts/2023-03-10/rewrite-this-blog-generator/index.html
+++ b/public/posts/2023-03-10/rewrite-this-blog-generator/index.html
@@ -9,7 +9,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>このブログのジェネレータを書き直した | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
diff --git a/static/hl.css b/static/hl.css
index fabe9de..275239a 100644
--- a/static/hl.css
+++ b/static/hl.css
@@ -1,214 +1,10 @@
-/* ruby -rrouge -e 'puts Rouge::Themes::Github.render(scope: ".highlight")' */
-.highlight table td { padding: 5px; }
-.highlight table pre { margin: 0; }
-.highlight .cm {
- color: #999988;
- font-style: italic;
-}
-.highlight .cp {
- color: #999999;
- font-weight: bold;
-}
-.highlight .c1 {
- color: #999988;
- font-style: italic;
-}
-.highlight .cs {
- color: #999999;
- font-weight: bold;
- font-style: italic;
-}
-.highlight .c, .highlight .ch, .highlight .cd, .highlight .cpf {
- color: #999988;
- font-style: italic;
-}
-.highlight .err {
- color: #a61717;
- background-color: #e3d2d2;
-}
-.highlight .gd {
- color: #000000;
- background-color: #ffdddd;
-}
-.highlight .ge {
- color: #000000;
- font-style: italic;
-}
-.highlight .gr {
- color: #aa0000;
-}
-.highlight .gh {
- color: #999999;
-}
-.highlight .gi {
- color: #000000;
- background-color: #ddffdd;
-}
-.highlight .go {
- color: #888888;
-}
-.highlight .gp {
- color: #555555;
-}
-.highlight .gs {
- font-weight: bold;
-}
-.highlight .gu {
- color: #aaaaaa;
-}
-.highlight .gt {
- color: #aa0000;
-}
-.highlight .kc {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kd {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kn {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kp {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kr {
- color: #000000;
- font-weight: bold;
-}
-.highlight .kt {
- color: #445588;
- font-weight: bold;
-}
-.highlight .k, .highlight .kv {
- color: #000000;
- font-weight: bold;
-}
-.highlight .mf {
- color: #009999;
-}
-.highlight .mh {
- color: #009999;
-}
-.highlight .il {
- color: #009999;
-}
-.highlight .mi {
- color: #009999;
-}
-.highlight .mo {
- color: #009999;
-}
-.highlight .m, .highlight .mb, .highlight .mx {
- color: #009999;
-}
-.highlight .sa {
- color: #000000;
- font-weight: bold;
-}
-.highlight .sb {
- color: #d14;
-}
-.highlight .sc {
- color: #d14;
-}
-.highlight .sd {
- color: #d14;
-}
-.highlight .s2 {
- color: #d14;
-}
-.highlight .se {
- color: #d14;
-}
-.highlight .sh {
- color: #d14;
-}
-.highlight .si {
- color: #d14;
-}
-.highlight .sx {
- color: #d14;
-}
-.highlight .sr {
- color: #009926;
-}
-.highlight .s1 {
- color: #d14;
-}
-.highlight .ss {
- color: #990073;
-}
-.highlight .s, .highlight .dl {
- color: #d14;
-}
-.highlight .na {
- color: #008080;
-}
-.highlight .bp {
- color: #999999;
-}
-.highlight .nb {
- color: #0086B3;
-}
-.highlight .nc {
- color: #445588;
- font-weight: bold;
-}
-.highlight .no {
- color: #008080;
-}
-.highlight .nd {
- color: #3c5d5d;
- font-weight: bold;
-}
-.highlight .ni {
- color: #800080;
-}
-.highlight .ne {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nf, .highlight .fm {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nl {
- color: #990000;
- font-weight: bold;
-}
-.highlight .nn {
- color: #555555;
-}
-.highlight .nt {
- color: #000080;
-}
-.highlight .vc {
- color: #008080;
-}
-.highlight .vg {
- color: #008080;
-}
-.highlight .vi {
- color: #008080;
-}
-.highlight .nv, .highlight .vm {
- color: #008080;
-}
-.highlight .ow {
- color: #000000;
- font-weight: bold;
-}
-.highlight .o {
- color: #000000;
- font-weight: bold;
-}
-.highlight .w {
- color: #bbbbbb;
-}
-.highlight {
- background-color: #f8f8f8;
-} \ No newline at end of file
+pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
+ Theme: GitHub
+ Description: Light theme as seen on github.com
+ Author: github.com
+ Maintainer: @Hirse
+ Updated: 2021-05-15
+
+ Outdated base version: https://github.com/primer/github-syntax-light
+ Current colors taken from GitHub's CSS
+*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0} \ No newline at end of file