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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cook-ssg",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Cook your static pages into a beautifully performing site. Static site generation the web platform way.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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: () => parsed.document.toString(),
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
  }