diff options
Diffstat (limited to 'nuldoc-src/docbook/to_html.ts')
| -rw-r--r-- | nuldoc-src/docbook/to_html.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/nuldoc-src/docbook/to_html.ts b/nuldoc-src/docbook/to_html.ts index 24be139..0672ea6 100644 --- a/nuldoc-src/docbook/to_html.ts +++ b/nuldoc-src/docbook/to_html.ts @@ -1,5 +1,4 @@ import hljs from "hljs/highlight.min.js"; -import hljsPhp from "hljs/languages/php.min.js"; import { Document } from "./document.ts"; import { DocBookError } from "../errors.ts"; import { @@ -9,6 +8,7 @@ import { forEachChildRecursively, Node, removeChildElements, + Text, } from "../dom.ts"; export default function toHtml(doc: Document): Document { @@ -298,13 +298,17 @@ function highlightPrograms(doc: Document) { if (!language) { return; } - const sourceCode = codeElement.children[0].content; + const sourceCode = (codeElement.children[0] as Text).content; - const validLanguage = hljs.getLanguage(language) ? language : "plaintext"; - const highlighted = - hljs.highlight(sourceCode, { language: validLanguage }).value; + const validLanguage = + (hljs as { getLanguage: (s: string) => string }).getLanguage(language) + ? language + : "plaintext"; + const highlighted = (hljs as { + highlight: (s: string, o: { language: string }) => { value: string }; + }).highlight(sourceCode, { language: validLanguage }).value; - codeElement.children[0].content = highlighted; + (codeElement.children[0] as Text).content = highlighted; codeElement.attributes.set("class", "highlight"); }); } |
