]> Lady’s Gitweb - GitWikiWeb/commitdiff
Support arbitrary use of @as 0.2.1
authorLady <redacted>
Sat, 29 Jul 2023 00:18:15 +0000 (17:18 -0700)
committerLady <redacted>
Sat, 29 Jul 2023 00:18:15 +0000 (17:18 -0700)
build.js

index ca07283ba29bb747f7b353661da5b224607e554c..b50fe3d4c2c83da96c1eb154d806443e8a7a1d16 100644 (file)
--- a/build.js
+++ b/build.js
@@ -302,29 +302,6 @@ class GitWikiWebPage {
             e.children.push(...links_section);
           },
         },
             e.children.push(...links_section);
           },
         },
-        emph: {
-          enter: (_) => {},
-          exit: (e) => {
-            const attributes = e.attributes ?? NIL;
-            const { as } = attributes;
-            if (as) {
-              delete attributes.as;
-              if (
-                as == "b" || as == "cite" || as == "i" || as == "u"
-              ) {
-                return [
-                  rawInline`<${as}>`,
-                  ...e.children,
-                  rawInline`</${as}>`,
-                ];
-              } else {
-                /* do nothing */
-              }
-            } else {
-              /* do nothing */
-            }
-          },
-        },
         hard_break: {
           enter: (_) => {
             if (titleSoFar != null) {
         hard_break: {
           enter: (_) => {
             if (titleSoFar != null) {
@@ -513,6 +490,38 @@ class GitWikiWebPage {
   }
 }
 
   }
 }
 
+{
+  // Patches for Djot HTML renderer.
+  const { HTMLRenderer: { prototype: htmlRendererPrototype } } = djot;
+  const { inTags: upstreamInTags } = htmlRendererPrototype;
+  htmlRendererPrototype.inTags = function (
+    tag,
+    node,
+    newlines,
+    extraAttrs = undefined,
+  ) {
+    const attributes = node.attributes ?? NIL;
+    if ("as" in attributes) {
+      const newTag = attributes.as;
+      delete attributes.as;
+      return upstreamInTags.call(
+        this,
+        newTag,
+        node,
+        newlines,
+        extraAttrs,
+      );
+    } else {
+      return upstreamInTags.call(
+        this,
+        tag,
+        node,
+        newlines,
+        extraAttrs,
+      );
+    }
+  };
+}
 {
   const config = await getRemoteContent("config.yaml").then((yaml) =>
     parseYaml(yaml, { schema: JSON_SCHEMA })
 {
   const config = await getRemoteContent("config.yaml").then((yaml) =>
     parseYaml(yaml, { schema: JSON_SCHEMA })
This page took 0.092137 seconds and 4 git commands to generate.