Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created November 7, 2010 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DTrejo/665933 to your computer and use it in GitHub Desktop.
Save DTrejo/665933 to your computer and use it in GitHub Desktop.
how to get doctype from jsdom
var text = '<!DOCTYPE HTML><html lang="en"><head><title>Woo</title></head><body></body></html>';
var jsdom = require('jsdom').jsdom;
var window = jsdom(text).createWindow();
// here's the doctype
console.log(window.document.doctype+'');
@webjay
Copy link

webjay commented May 26, 2016

and you can get the source with doctype with jsdom.serializeDocument(window.document)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment