@gerhobbelt/xml-beautifier

1.0.2-1 • Public • Published

XML, But Prettier

Build Status NPM version

This module is a fork of jonathanp/xml-beautifier.

This module beautifies XML documents by putting each tag and text node on their own line and correctly indenting everything.

Can be used e.g. if you're using React as a static page generator and (for some reason) need the generated HTML to be more human-readable.

Install

$ npm install --save xml-but-prettier

Usage

The module's function signature is xmlButPrettier(xml:String, options:Object).

import xmlButPrettier from 'xml-but-prettier';

const xml = xmlButPrettier('<div><span>foo</span></div>');
console.log(xml); // => will output correctly indented elements

Options

  • indentor: a custom string to use for indenting things
  • textNodesOnSameLine: compresses text nodes onto the same line as their containing tags

License

MIT.

/@gerhobbelt/xml-beautifier/

    Package Sidebar

    Install

    npm i @gerhobbelt/xml-beautifier

    Weekly Downloads

    1

    Version

    1.0.2-1

    License

    MIT

    Unpacked Size

    2.31 MB

    Total Files

    9

    Last publish

    Collaborators

    • gerhobbelt