]>
Lady’s Gitweb - Blog/blob - build.js
a9d2bafc0bb5f624d5654dd3a7f950586e1e5657
   1 #!/usr/bin
/env 
-S deno run 
--allow
-read 
--allow
-write
 
   3 // Copyright © 2023 Lady [@ Lady’s Computer]. 
   5 // This Source Code Form is subject to the terms of the Mozilla Public 
   6 // License, v. 2.0. If a copy of the MPL was not distributed with this 
   7 // file, You can obtain one at <https://mozilla.org/MPL/2.0/>. 
   9 import hljs 
from "npm:highlight.js@11.8.0"; 
  11 const processContent 
= (content
) => { 
  12   if (content 
== null || Object(content
) instanceof String
) { 
  14   } else if (Array
.isArray(content
)) { 
  15     // The provided content is an array. 
  16     content
.forEach(processContent
); 
  18     for (const child 
of Array
.from(content
)) { 
  19       applyHighlighting(child
); 
  24 const applyHighlighting 
= (node
) => { 
  26     node
.localName 
== "pre" && node
.childNodes
.length 
== 1 && 
  27     node
.firstChild
.localName 
== "code" 
  29     const code 
= node
.firstChild
; 
  30     const language 
= /language-(.*)/u.exec(code
.getAttribute("class")) 
  34         const { value: highlight 
} = hljs
.highlight( 
  35           node
.firstChild
.textContent
, 
  38         const nodes 
= new DOMParser().parseFromString( 
  39           `<!DOCTYPE html><html><body>${highlight}</body></html>`, 
  41         ).documentElement
.lastChild
.childNodes
; 
  44           `hljs ${code.getAttribute("class")}`, 
  46         code
.textContent 
= ""; 
  47         for (const node 
of Array
.from(nodes
)) { 
  48           code
.appendChild(code
.ownerDocument
.importNode(node
, true)); 
  54   } else if (node
.nodeType 
== 1) { 
  55     Array
.from(node
.childNodes
).forEach(applyHighlighting
); 
  56   } else if (node
.nodeType 
== 3) { 
  57     node
.textContent 
= node
.textContent
.replaceAll(":—", ":\u2060—"); 
  61 globalThis
.bj
ørnTransformMetadata 
= (metadata
, _type
) => { 
  62   processContent(metadata
.content
); 
  63   processContent(metadata
.summary
); 
  66 globalThis
.bj
ørnTransformFeedHTML 
= (document
, _metadata
) => { 
  67   const LMN 
= Lemon
.bind({ document 
}); 
  68   const h1 
= document
.getElementsByTagNameNS( 
  69     "http://www.w3.org/1999/xhtml", 
  72   const link 
= LMN
.a
.href("/")``; 
  73   for (const child 
of Array
.from(h1
.childNodes
)) { 
  74     link
.appendChild(child
); 
  80   "https://git.ladys.computer/Beorn/blob_plain/0.2.3:/build.js" 
 
This page took 0.061279 seconds  and 3 git commands  to generate.