From 98c4b2527ea57f6b6412c9ae7c0448bb17e38515 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Thu, 21 Nov 2024 12:06:27 +0000 Subject: [PATCH 1/3] replace encoded slash character in page titles --- reference.page.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reference.page.jsx b/reference.page.jsx index e13215e06..e27b923e5 100644 --- a/reference.page.jsx +++ b/reference.page.jsx @@ -24,7 +24,12 @@ export default function* () { let title = ""; try { const match = titleRegexp.exec(content); - title = match[1].slice(0, -"documentation".length) + "- Deno Docs"; + title = + match[1].slice(0, -"documentation".length).replace("/", "/") + + "- Deno Docs"; + if (title.includes("/")) { + console.log(title); + } } catch (e) { if (!file.path.endsWith("prototype.html")) { console.error(file.path); From 3848e01e034a75993a4585741b3737628e3658fc Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Thu, 21 Nov 2024 12:07:05 +0000 Subject: [PATCH 2/3] replace encoded slash character in page titles --- reference.page.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/reference.page.jsx b/reference.page.jsx index e27b923e5..f348c0a58 100644 --- a/reference.page.jsx +++ b/reference.page.jsx @@ -27,9 +27,6 @@ export default function* () { title = match[1].slice(0, -"documentation".length).replace("/", "/") + "- Deno Docs"; - if (title.includes("/")) { - console.log(title); - } } catch (e) { if (!file.path.endsWith("prototype.html")) { console.error(file.path); From f0f77b75938181a2fa516a49852920079e28e1d5 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Thu, 21 Nov 2024 13:22:36 +0000 Subject: [PATCH 3/3] use unencode from std library --- deno.json | 1 + deno.lock | 13 +++++++++++++ reference.page.jsx | 8 +++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index 8a234c7ce..1ac127d0a 100644 --- a/deno.json +++ b/deno.json @@ -4,6 +4,7 @@ "@std/assert": "jsr:@std/assert@^1.0.6", "@std/dotenv": "jsr:@std/dotenv@^0.225.2", "@std/fs": "jsr:@std/fs@^0.229.3", + "@std/html": "jsr:@std/html@^1.0.3", "@std/media-types": "jsr:@std/media-types@^1.0.3", "ga4": "https://raw.githubusercontent.com/denoland/ga4/04a1ce209116f158b5ef1658b957bdb109db68ed/mod.ts", "lume/": "https://deno.land/x/lume@v2.4.1/", diff --git a/deno.lock b/deno.lock index 5fe9bbd17..cca2aaad8 100644 --- a/deno.lock +++ b/deno.lock @@ -2,6 +2,7 @@ "version": "4", "specifiers": { "jsr:@davidbonnet/astring@1.8.6": "1.8.6", + "jsr:@std/assert@^1.0.6": "1.0.8", "jsr:@std/cli@1.0.6": "1.0.6", "jsr:@std/cli@^1.0.6": "1.0.6", "jsr:@std/collections@^1.0.5": "1.0.9", @@ -18,7 +19,9 @@ "jsr:@std/fs@^1.0.4": "1.0.5", "jsr:@std/fs@~0.229.3": "0.229.3", "jsr:@std/html@1.0.3": "1.0.3", + "jsr:@std/html@^1.0.3": "1.0.3", "jsr:@std/http@1.0.9": "1.0.9", + "jsr:@std/internal@^1.0.5": "1.0.5", "jsr:@std/io@0.225": "0.225.0", "jsr:@std/json@1": "1.0.1", "jsr:@std/jsonc@1.0.1": "1.0.1", @@ -68,6 +71,12 @@ "@deno/gfm@0.8.2": { "integrity": "a7528367cbd954a2d0de316bd0097ee92f06d2cb66502c8574de133ed223424f" }, + "@std/assert@1.0.8": { + "integrity": "ebe0bd7eb488ee39686f77003992f389a06c3da1bbd8022184804852b2fa641b", + "dependencies": [ + "jsr:@std/internal" + ] + }, "@std/cli@1.0.6": { "integrity": "d22d8b38c66c666d7ad1f2a66c5b122da1704f985d3c47f01129f05abb6c5d3d" }, @@ -120,6 +129,9 @@ "jsr:@std/streams" ] }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + }, "@std/io@0.225.0": { "integrity": "c1db7c5e5a231629b32d64b9a53139445b2ca640d828c26bf23e1c55f8c079b3" }, @@ -1751,6 +1763,7 @@ "jsr:@std/assert@^1.0.6", "jsr:@std/dotenv@~0.225.2", "jsr:@std/fs@~0.229.3", + "jsr:@std/html@^1.0.3", "jsr:@std/media-types@^1.0.3", "npm:googleapis@144", "npm:tailwindcss@^3.4.9" diff --git a/reference.page.jsx b/reference.page.jsx index f348c0a58..a81f1732d 100644 --- a/reference.page.jsx +++ b/reference.page.jsx @@ -1,4 +1,6 @@ import { walkSync } from "@std/fs/walk"; +import { unescape } from "@std/html/entities"; +import entityList from "@std/html/named-entity-list.json" with { type: "json" }; export const layout = "raw.tsx"; @@ -24,9 +26,9 @@ export default function* () { let title = ""; try { const match = titleRegexp.exec(content); - title = - match[1].slice(0, -"documentation".length).replace("/", "/") + - "- Deno Docs"; + const titleFirst = match[1].slice(0, -"documentation".length); + + title = unescape(titleFirst, { entityList }) + "- Deno Docs"; } catch (e) { if (!file.path.endsWith("prototype.html")) { console.error(file.path);