Skip to content

Commit f27ceae

Browse files
committed
don't loose DOCTYPE header in embed resource processing
1 parent d9f1872 commit f27ceae

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/core/pandoc/self-contained.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const pandocIngestSelfContainedContent = async (
4848

4949
// The raw html contents
5050
const contents = Deno.readTextFileSync(file);
51+
const doctypeMatch = contents.match(/^<!DOCTYPE.*?>/);
5152
const dom = await parseHtml(contents);
5253
await bundleModules(dom, workingDir);
5354

@@ -63,6 +64,9 @@ export const pandocIngestSelfContainedContent = async (
6364
cmd.push("--template", template);
6465
cmd.push("--output", filename);
6566
cmd.push("--metadata", "title=placeholder");
67+
if (doctypeMatch) {
68+
cmd.push("--variable", `doctype=${doctypeMatch[0]}`);
69+
}
6670
cmd.push("--embed-resources");
6771
if (resourcePath && resourcePath.length) {
6872
cmd.push("--resource-path", resourcePath.join(":"));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
$if(doctype)$$doctype$$endif$
12
$body$

0 commit comments

Comments
 (0)