2.0.0 • Published 4 years ago

domspace v2.0.0

Weekly downloads
4,486
License
BSD-3-Clause
Repository
-
Last release
4 years ago

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>
2.0.0

4 years ago

1.2.2

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago