From ee142efa60d6d934a52988fd43ea1f316543473b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 17 Mar 2023 02:29:37 +0900 Subject: refactor: simplify class manipulation --- nuldoc-src/docbook/to_html.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'nuldoc-src') diff --git a/nuldoc-src/docbook/to_html.ts b/nuldoc-src/docbook/to_html.ts index 0672ea6..7c21036 100644 --- a/nuldoc-src/docbook/to_html.ts +++ b/nuldoc-src/docbook/to_html.ts @@ -2,6 +2,7 @@ import hljs from "hljs/highlight.min.js"; import { Document } from "./document.ts"; import { DocBookError } from "../errors.ts"; import { + addClass, Element, findFirstChildElement, forEachChild, @@ -195,8 +196,7 @@ function transformProgramListingElement(doc: Document) { } n.name = "pre"; - const preClass = n.attributes.get("class"); - n.attributes.set("class", preClass ? preClass + " highlight" : "highlight"); + addClass(n, "highlight"); const codeElement: Element = { kind: "element", name: "code", @@ -214,8 +214,7 @@ function transformLiteralLayoutElement(doc: Document) { } n.name = "pre"; - const preClass = n.attributes.get("class"); - n.attributes.set("class", preClass ? preClass + " highlight" : "highlight"); + addClass(n, "highlight"); const codeElement: Element = { kind: "element", name: "code", -- cgit v1.2.3-70-g09d2