diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-05-17 01:50:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-05-17 01:50:38 +0900 |
| commit | 36ef8dcf0c87d646970af855db53e5a7f6c51af2 (patch) | |
| tree | acf44f3dc8e60d00e2c5e8c751edb59180bc8480 /vhosts/blog/nuldoc-src/djot | |
| parent | 546e0bb2f992b31d3cb480948a00100660ee5d9d (diff) | |
| download | nsfisis.dev-36ef8dcf0c87d646970af855db53e5a7f6c51af2.tar.gz nsfisis.dev-36ef8dcf0c87d646970af855db53e5a7f6c51af2.tar.zst nsfisis.dev-36ef8dcf0c87d646970af855db53e5a7f6c51af2.zip | |
feat(blog/nuldoc): allow codeblock to have line number
Diffstat (limited to 'vhosts/blog/nuldoc-src/djot')
| -rw-r--r-- | vhosts/blog/nuldoc-src/djot/djot2ndoc.ts | 3 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/djot/to_html.ts | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts b/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts index 55b63a0d..fa0365b0 100644 --- a/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts +++ b/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts @@ -133,6 +133,9 @@ function processCodeBlock(node: DjotCodeBlock): Element { if (node.attributes?.filename) { attributes.set("filename", node.attributes.filename); } + if (node.attributes?.numbered) { + attributes.set("numbered", "true"); + } return { kind: "element", name: "codeblock", diff --git a/vhosts/blog/nuldoc-src/djot/to_html.ts b/vhosts/blog/nuldoc-src/djot/to_html.ts index b64c3d99..e2d6a9b6 100644 --- a/vhosts/blog/nuldoc-src/djot/to_html.ts +++ b/vhosts/blog/nuldoc-src/djot/to_html.ts @@ -367,6 +367,7 @@ async function transformAndHighlightCodeBlockElement(doc: Document) { const language = n.attributes.get("language") || "text"; const filename = n.attributes.get("filename"); + const numbered = n.attributes.get("numbered"); const sourceCodeNode = n.children[0] as Text | RawHTML; const sourceCode = sourceCodeNode.content.trimEnd(); @@ -382,6 +383,10 @@ async function transformAndHighlightCodeBlockElement(doc: Document) { n.attributes.set("class", "codeblock"); n.attributes.delete("language"); + if (numbered === "true") { + n.attributes.delete("numbered"); + addClass(n, "numbered"); + } if (filename) { n.attributes.delete("filename"); |
