Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

domspace

1.2.1 • 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>

Keywords

none

install

npm i domspace

Downloadsweekly downloads

784

version

1.2.1

license

BSD-3-Clause

last publish

collaborators

  • avatar
Report a vulnerability