cook-ssg 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -571,9 +571,16 @@ function newDOM({src, options}) {
|
|
|
571
571
|
// We wrap it to provide a compatible interface for existing plugins
|
|
572
572
|
jsdom.parseCount += 1;
|
|
573
573
|
const parsed = parseHTML(src);
|
|
574
|
+
// linkedom always writes <!DOCTYPE html> (uppercase). Keep the doctype the
|
|
575
|
+
// author wrote (e.g. lowercase <!doctype html>, which HTML linters such as
|
|
576
|
+
// html-validate's doctype-style rule require) so output matches source.
|
|
577
|
+
const sourceDoctype = /^\s*(<!doctype\b[^>]*>)/i.exec(src)?.[1];
|
|
574
578
|
return {
|
|
575
579
|
window: { document: parsed.document },
|
|
576
|
-
serialize: () =>
|
|
580
|
+
serialize: () => {
|
|
581
|
+
const out = parsed.document.toString();
|
|
582
|
+
return sourceDoctype ? out.replace(/^<!doctype\b[^>]*>/i, sourceDoctype) : out;
|
|
583
|
+
},
|
|
577
584
|
_document: parsed.document,
|
|
578
585
|
};
|
|
579
586
|
}
|