diff --git a/src/core/pandoc/self-contained.ts b/src/core/pandoc/self-contained.ts index ca3e9f55aee..252f7181466 100644 --- a/src/core/pandoc/self-contained.ts +++ b/src/core/pandoc/self-contained.ts @@ -48,11 +48,15 @@ export const pandocIngestSelfContainedContent = async ( // The raw html contents const contents = Deno.readTextFileSync(file); + const doctypeMatch = contents.match(/^/); const dom = await parseHtml(contents); await bundleModules(dom, workingDir); const input: string[] = []; input.push("````````{=html}"); + if (doctypeMatch) { + input.push(doctypeMatch[0]); + } input.push(dom.documentElement!.outerHTML); input.push("````````"); diff --git a/tests/docs/smoke-all/2025/04/04/12295.qmd b/tests/docs/smoke-all/2025/04/04/12295.qmd new file mode 100644 index 00000000000..13a9eff71dc --- /dev/null +++ b/tests/docs/smoke-all/2025/04/04/12295.qmd @@ -0,0 +1,28 @@ +--- +title: DOCTYPE is not lost when using embed-resources +embed-resources: true +_quarto: + tests: + html: + ensureHtmlElements: + - [] + - [] + ensureFileRegexMatches: + - ['\<\!DOCTYPE html\>'] + - [] + revealjs: + ensureHtmlElements: + - [] + - [] + ensureFileRegexMatches: + - ['\<\!DOCTYPE html\>'] + - [] +--- + +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. + +## Header + +```bash +quarto render --help +``` \ No newline at end of file