diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-04-25 22:36:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-04-25 22:36:47 +0900 |
| commit | b206b17dfffee47940d391dd8dfbcfd79cc6861e (patch) | |
| tree | 404a7b71882e1f2d08c7170b0e2e6e674ab632ae /vhosts/blog/nuldoc-src/renderers/html.ts | |
| parent | a3dd384695b5da93e69379be862eb7f0968c187b (diff) | |
| download | nsfisis.dev-b206b17dfffee47940d391dd8dfbcfd79cc6861e.tar.gz nsfisis.dev-b206b17dfffee47940d391dd8dfbcfd79cc6861e.tar.zst nsfisis.dev-b206b17dfffee47940d391dd8dfbcfd79cc6861e.zip | |
feat(blog/nuldoc): add `defer` attribute to some `script` tags
Diffstat (limited to 'vhosts/blog/nuldoc-src/renderers/html.ts')
| -rw-r--r-- | vhosts/blog/nuldoc-src/renderers/html.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/vhosts/blog/nuldoc-src/renderers/html.ts b/vhosts/blog/nuldoc-src/renderers/html.ts index ec77eb4d..b9336b53 100644 --- a/vhosts/blog/nuldoc-src/renderers/html.ts +++ b/vhosts/blog/nuldoc-src/renderers/html.ts @@ -183,9 +183,14 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string { s += " "; for (let i = 0; i < attributes.length; i++) { const [name, value] = attributes[i]; - s += `${name === "className" ? "class" : name}="${ - encodeSpecialCharacters(value) - }"`; + if (name === "defer" && value === "true") { + // TODO + s += "defer"; + } else { + s += `${name === "className" ? "class" : name}="${ + encodeSpecialCharacters(value) + }"`; + } if (i !== attributes.length - 1) { s += " "; } @@ -246,6 +251,7 @@ function indent(ctx: Context): string { function getElementAttributes(e: Element): [string, string][] { return [...e.attributes.entries()] .filter((a) => !a[0].startsWith("--")) + .filter((a) => a[1] !== undefined) .sort( (a, b) => { // Special rules: |
