New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

domspace

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domspace

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

1.2.2
Version published
Weekly downloads
5.3K
17.68%
Maintainers
1
Weekly downloads
 
Created

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>

FAQs

Package last updated on 23 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts