]> Lady’s Gitweb - GitWikiWeb/commitdiff
Move symbol definition into external config file
authorLady <redacted>
Fri, 28 Jul 2023 09:24:29 +0000 (02:24 -0700)
committerLady <redacted>
Fri, 28 Jul 2023 09:30:16 +0000 (02:30 -0700)
This file is planned to be used for other site configuration as well.

build.js
config.yaml [new file with mode: 0644]

index df9c016600b3fdf9539de47d162d7ff944fc9dc9..e8b700344c66acd85b81731b1f9324d68bdd3954 100644 (file)
--- a/build.js
+++ b/build.js
 import {
   emptyDir,
   ensureDir,
 import {
   emptyDir,
   ensureDir,
-} from "https://deno.land/std@0.195.0/fs/mod.ts";
+} from "https://deno.land/std@0.196.0/fs/mod.ts";
+import {
+  JSON_SCHEMA,
+  parse as parseYaml,
+} from "https://deno.land/std@0.196.0/yaml/mod.ts";
 import djot from "npm:@djot/djot@0.2.3";
 import { Parser } from "npm:htmlparser2@9.0.0";
 import { DomHandler, Element, Text } from "npm:domhandler@5.0.3";
 import djot from "npm:@djot/djot@0.2.3";
 import { Parser } from "npm:htmlparser2@9.0.0";
 import { DomHandler, Element, Text } from "npm:domhandler@5.0.3";
@@ -217,7 +221,7 @@ class GitWikiWebPage {
   #internalLinks = new Set();
   #externalLinks = new Map();
 
   #internalLinks = new Set();
   #externalLinks = new Map();
 
-  constructor(namespace, name, ast, source) {
+  constructor(namespace, name, ast, source, config) {
     const internalLinks = this.#internalLinks;
     const externalLinks = this.#externalLinks;
     const sections = Object.create(null);
     const internalLinks = this.#internalLinks;
     const externalLinks = this.#externalLinks;
     const sections = Object.create(null);
@@ -480,23 +484,8 @@ class GitWikiWebPage {
                 String.fromCodePoint(parseInt(codepoint, 16))
               }`;
             } else {
                 String.fromCodePoint(parseInt(codepoint, 16))
               }`;
             } else {
-              return {
-                "--8": str`${"—\u2060:\u202F"}`, // reverse puppyprick
-                "8--": str`${"\u202F:\u2060—"}`, // forward puppyprick
-                sp: rawInline` `, // space
-                nbsp: str`${"\xA0"}`, // no‐break space
-                cgj: str`${"\u034F"}`, // combining grapheme joiner
-                ensp: str`${"\u2002"}`, // enspace
-                emsp: str`${"\u2003"}`, // emspace
-                figsp: str`${"\u2007"}`, // figure space
-                zwsp: str`${"\u200B"}`, // zero‐width space
-                zwnj: str`${"\u200C"}`, // zero‐width nonjoiner
-                zwj: str`${"\u200D"}`, // zero‐width joiner
-                nnbsp: str`${"\u202F"}`, // narrow no‐break space
-                mathsp: str`${"\u205F"}`, // math space
-                wj: str`${"\u2060"}`, // word joiner
-                fwsp: str`${"\u3000"}`, // fullwidth space
-              }[alias] ?? e;
+              const resolved = config.symbols?.[alias];
+              return resolved != null ? str`${resolved}` : e;
             }
           },
         },
             }
           },
         },
@@ -524,6 +513,9 @@ class GitWikiWebPage {
 }
 
 {
 }
 
 {
+  const config = await getRemoteContent("config.yaml").then((yaml) =>
+    parseYaml(yaml, { schema: JSON_SCHEMA })
+  );
   const ls = new Deno.Command("git", {
     args: ["ls-tree", "-rz", "live"],
     stdout: "piped",
   const ls = new Deno.Command("git", {
     args: ["ls-tree", "-rz", "live"],
     stdout: "piped",
@@ -597,6 +589,7 @@ class GitWikiWebPage {
                     console.warn(`Djot(${reference}): ${$.render()}`),
                 }),
                 source,
                     console.warn(`Djot(${reference}): ${$.render()}`),
                 }),
                 source,
+                config,
               );
               const reference = `${namespace}:${pageName}`;
               pages.set(reference, page);
               );
               const reference = `${namespace}:${pageName}`;
               pages.set(reference, page);
@@ -618,6 +611,7 @@ class GitWikiWebPage {
             console.warn(`Djot(${reference}): ${$.render()}`),
         }),
         source,
             console.warn(`Djot(${reference}): ${$.render()}`),
         }),
         source,
+        config,
       );
       pages.set(reference, page);
     }
       );
       pages.set(reference, page);
     }
diff --git a/config.yaml b/config.yaml
new file mode 100644 (file)
index 0000000..555db2b
--- /dev/null
@@ -0,0 +1,16 @@
+# Modify this file to configure your GitWikiWeb instance.
+symbols:
+  nbsp: "\xA0" # no‐break space
+  cgj: "\u034F" # combining grapheme joiner
+  ensp: "\u2002" # enspace
+  emsp: "\u2003" # emspace
+  figsp: "\u2007" # figure space
+  zwsp: "\u200B" # zero‐width space
+  zwnj: "\u200C" # zero‐width nonjoiner
+  zwj: "\u200D" # zero‐width joiner
+  nnbsp: "\u202F" # narrow no‐break space
+  mathsp: "\u205F" # math space
+  wj: "\u2060" # word joiner
+  fwsp: "\u3000" # fullwidth space
+  as_text: "\uFE0E" # text variation
+  as_emoji: "\uFE0F" # emoji variation
This page took 0.030137 seconds and 4 git commands to generate.