aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/docbook
diff options
context:
space:
mode:
Diffstat (limited to 'nuldoc-src/docbook')
-rw-r--r--nuldoc-src/docbook/to_html.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/nuldoc-src/docbook/to_html.ts b/nuldoc-src/docbook/to_html.ts
index c824780..9f176d4 100644
--- a/nuldoc-src/docbook/to_html.ts
+++ b/nuldoc-src/docbook/to_html.ts
@@ -9,6 +9,7 @@ import {
forEachChild,
forEachChildRecursively,
Node,
+ RawHTML,
removeChildElements,
Text,
} from "../dom.ts";
@@ -239,6 +240,7 @@ function transformNoteElement(doc: Document) {
children: [{
kind: "text",
content: "Note",
+ raw: true,
}],
};
const contentElement: Element = {
@@ -298,12 +300,18 @@ function highlightPrograms(doc: Document) {
if (!language) {
return;
}
- const sourceCode = (codeElement.children[0] as Text).content;
+ const sourceCodeNode = codeElement.children[0] as Text | RawHTML;
+ const sourceCode = sourceCodeNode.content;
+
+ if (!hljs.getLanguage(language)) {
+ return;
+ }
const highlighted =
hljs.highlight(sourceCode, { language: language }).value;
- (codeElement.children[0] as Text).content = highlighted;
+ sourceCodeNode.content = highlighted;
+ sourceCodeNode.raw = true;
codeElement.attributes.set("class", "highlight");
});
}