Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created November 29, 2012 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save twolfson/4167514 to your computer and use it in GitHub Desktop.
Save twolfson/4167514 to your computer and use it in GitHub Desktop.
Pretty print HTML but not JS test
/node_modules
var html = require('html'),
fs = require('fs'),
content = fs.readFileSync('minified.html', 'utf8'),
skipTags = ['script'],
prettyOptions = {'unformatted': ['script']},
beautifulContent = html.prettyPrint(content, prettyOptions),
beautifulContentDefault = html.prettyPrint(content);
// console.log(beautifulContent);
console.log(beautifulContentDefault);
<div><div><div><script>console.log('hey');console.log('what\'s up doc?');console.log('nada mucho senor');</script></div></div></div>
{
"name": "gist-4167514",
"version": "0.0.0",
"description": "Pretty print HTML but not JS test",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://gist.github.com/4167514.git gist-4167514"
},
"author": "Todd Wolfson",
"license": "MIT",
"dependencies": {
"html": "0.0.7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment