main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | # XML, But Prettier
|
---|
2 |
|
---|
3 | [![Build Status][travis-image]][travis-url]
|
---|
4 | [![NPM version][npm-image]][npm-url]
|
---|
5 |
|
---|
6 | _This module is a fork of [jonathanp/xml-beautifier][upstream-github]._
|
---|
7 |
|
---|
8 | This module beautifies XML documents by putting each tag and text node on their own line and correctly indenting everything.
|
---|
9 |
|
---|
10 | Can be used e.g. if you're using [React as a static page generator][react] and (for some reason) need the generated HTML to be more human-readable.
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Install
|
---|
14 |
|
---|
15 | ```
|
---|
16 | $ npm install --save xml-beautifier
|
---|
17 | ```
|
---|
18 |
|
---|
19 |
|
---|
20 | ## Usage
|
---|
21 |
|
---|
22 | The module's function signature is `xmlButPrettier(xml:String, options:Object)`.
|
---|
23 |
|
---|
24 | ```js
|
---|
25 | import xmlButPrettier from 'xml-but-prettier';
|
---|
26 |
|
---|
27 | const xml = xmlButPrettier('<div><span>foo</span></div>');
|
---|
28 | console.log(xml); // => will output correctly indented elements
|
---|
29 | ```
|
---|
30 |
|
---|
31 | #### Options
|
---|
32 | - `indentor`: a custom string to use for indenting things
|
---|
33 | - `textNodesOnSameLine`: compresses text nodes onto the same line as their containing tags
|
---|
34 |
|
---|
35 | ## License
|
---|
36 |
|
---|
37 | MIT.
|
---|
38 |
|
---|
39 | [upstream-github]: https://github.com/jonathanp/xml-beautifier
|
---|
40 | [npm-url]: https://npmjs.org/package/xml-but-prettier
|
---|
41 | [npm-image]: https://badge.fury.io/js/xml-but-prettier.svg
|
---|
42 | [travis-image]: https://travis-ci.org/shockey/xml-but-prettier.svg
|
---|
43 | [travis-url]: https://travis-ci.org/shockey/xml-but-prettier
|
---|
44 | [react]: https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup
|
---|
Note:
See
TracBrowser
for help on using the repository browser.