0.0.6 • Published 11 years ago
html-outline v0.0.6
html-outline
streaming transform html to a plaintext DOM outline.
Usage
var outline = require('html-outline');
var strm = outline({indent: '..'});
strm.pipe(process.stdout);
strm.write('<html><body><div><p><img></p><p></p><ul><li></li></ul></div></body></html>')Outputs:
html
..body
....div
......p
........img
......p
......ul
........liOptions
Options, with their defaults:
{
indent: ' ',
minDepth: 0,
maxDepth: undefined,
selector: '*',
attributes: false,
classNames: false
}indentis a stringish; repeateddepthtimes and prepended to each element name.minDepthandmaxDepthrefer do depth in the DOM tree, with the first element considered depth 0. Indentation repsectsminDepth.selectoris a css selector (or array of them) supported by cssauron, and can be used to filter the outline. Any elements matching the provided selector(s) and all of their children (up tomaxDepth) will be included. (So, e.g.,{minDepth: 2}and{selector: 'div'}would do the same thing in the example above.)attributesflag determines whether or not to print attributes after the element name (e.g.,img[class="bray" src="img/donkey.jpg"])classNamesflag determines whether or not to print class names, e.g.,div.container.
Note: these are all also available as command line options: --classNames=true,etc.