For each local HTML script tag, calls a function with the code inside the tag and replaces the code with the return value
npm install html-script-hook tag found in a HTML file. Whatever the callback returns becomes the new code in the section. To leave the code exactly the same, simply callback with the same argument that was passed in.Originally this was created to help Istanbul instrument JavaScript in a HTML file so that it can be recognized for code coverage. But it can also support other tools that would want to have access to or modify the tag. For example: documentation generators, code analysis tools, style analysis, linters, obfuscation, etc.
npm install html-script-hook
Start with a HTML file:
`` html`
This is a test.
Run the parser on test.html:
` javascript
var fs = require("fs");
var testParser = require("html-script-hook");
var html = fs.readFileSync("test.html", {
encoding: "utf8"
});
// callback receives code from