Skip to content

Commit efe3a9d

Browse files
authored
Merge pull request #12455 from quarto-dev/fix/embed-doctype
don't loose DOCTYPE header in embed resource processing
2 parents efef4d7 + caae7f2 commit efe3a9d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/core/pandoc/self-contained.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ 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

5455
const input: string[] = [];
5556
input.push("````````{=html}");
57+
if (doctypeMatch) {
58+
input.push(doctypeMatch[0]);
59+
}
5660
input.push(dom.documentElement!.outerHTML);
5761
input.push("````````");
5862

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: DOCTYPE is not lost when using embed-resources
3+
embed-resources: true
4+
_quarto:
5+
tests:
6+
html:
7+
ensureHtmlElements:
8+
- []
9+
- []
10+
ensureFileRegexMatches:
11+
- ['\<\!DOCTYPE html\>']
12+
- []
13+
revealjs:
14+
ensureHtmlElements:
15+
- []
16+
- []
17+
ensureFileRegexMatches:
18+
- ['\<\!DOCTYPE html\>']
19+
- []
20+
---
21+
22+
Example from https://github.com/quarto-dev/quarto-cli/issues/12295: Not having DOCTYPE lead to browser using a Quirk mode for CSS, and not applying the standard HTML5.
23+
24+
## Header
25+
26+
```bash
27+
quarto render --help
28+
```

0 commit comments

Comments
 (0)