diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-06-15 12:54:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-06-15 12:57:11 +0900 |
| commit | c2252e60d3ab192271e4241943dd165087567af8 (patch) | |
| tree | d40c4b528c4f74b02af056ab667bf8a6d7e42544 /vhosts/blog/nuldoc-src | |
| parent | 796995ca280f554a25b24d3e03a028a5a479d9f2 (diff) | |
| download | nsfisis.dev-c2252e60d3ab192271e4241943dd165087567af8.tar.gz nsfisis.dev-c2252e60d3ab192271e4241943dd165087567af8.tar.zst nsfisis.dev-c2252e60d3ab192271e4241943dd165087567af8.zip | |
feat(blog/nuldoc): add custom div block for edit
Diffstat (limited to 'vhosts/blog/nuldoc-src')
| -rw-r--r-- | vhosts/blog/nuldoc-src/djot/djot2ndoc.ts | 10 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/djot/to_html.ts | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts b/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts index fa0365b0..90b1289c 100644 --- a/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts +++ b/vhosts/blog/nuldoc-src/djot/djot2ndoc.ts @@ -737,6 +737,16 @@ function processDiv(node: DjotDiv): Element { }; } + if (node.attributes?.class === "edit") { + delete node.attributes.class; + return { + kind: "element", + name: "note", + attributes: convertAttributes(node.attributes), + children: node.children.map(processBlock), + }; + } + return { kind: "element", name: "div", diff --git a/vhosts/blog/nuldoc-src/djot/to_html.ts b/vhosts/blog/nuldoc-src/djot/to_html.ts index c765cb07..3a6c1e9f 100644 --- a/vhosts/blog/nuldoc-src/djot/to_html.ts +++ b/vhosts/blog/nuldoc-src/djot/to_html.ts @@ -199,14 +199,17 @@ function transformNoteElement(doc: Document) { return; } - // TODO: 今のセクションレベルに合わせた h* タグにしたい + const editatAttr = n.attributes?.get("editat"); + const operationAttr = n.attributes?.get("operation"); + const isEditBlock = editatAttr && operationAttr; + const labelElement: Element = { kind: "element", name: "div", attributes: new Map([["class", "admonition-label"]]), children: [{ kind: "text", - content: "NOTE", + content: isEditBlock ? `${editatAttr} ${operationAttr}` : "NOTE", raw: false, }], }; |
