domspace

2.0.0 • Public • Published

domspace

Adjust the text nodes in an HTML DOM so that the document is pretty-printed when serialized.

Note that the supplied node and its children will be altered. If you'd rather create a copy that's ready for pretty printing, you can deep-clone it first using the DOM API:

const prettyNode = domspace(node.cloneNode(true));

Installation

npm install domspace

Example

const domspace = require('domspace');
const myDiv = document.createElement('div');
myDiv.innerHTML = '<span><i>foo</i></span>';
domspace(myDiv);
console.log(myDiv.outerHTML);

Output:

<div>
  <span>
    <i>foo</i>
  </span>
</div>

Dependents (2)

Package Sidebar

Install

npm i domspace

Weekly Downloads

3,428

Version

2.0.0

License

BSD-3-Clause

Unpacked Size

6.9 kB

Total Files

9

Last publish

Collaborators

  • papandreou