{"name":"xml-formatter","version":"2.4.1","repository":{"type":"git","url":"git+https://github.com/chrisbottin/xml-formatter.git"},"bugs":{"url":"https://github.com/chrisbottin/xml-formatter/issues"},"homepage":"https://github.com/chrisbottin/xml-formatter#readme","description":"Converts a XML string into a human readable format (pretty print) while respecting the xml:space attribute","author":{"name":"Chris Bottin","email":"chrisbottin@gmail.com"},"license":"MIT","main":"index.js","scripts":{"test":"mocha","prepublishOnly":"eslint . && npm test && npm run dist:prepare && npm run dist:build","dist:prepare":"rm -rf ./dist && mkdir -p ./dist/browser","dist:build":"browserify -r ./index.js:xml-formatter -o ./dist/browser/xml-formatter.js"},"engines":{"node":">= 10"},"keywords":["xml","pretty","print","pretty-print","indent","parser","formatter","xml:space","preserve"],"dependencies":{"xml-parser-xo":"^3.1.2"},"devDependencies":{"browserify":"^13.1.1","chai":"^4.3.4","eslint":"^6.8.0","glob":"^7.1.7","mocha":"^6.2.1"},"gitHead":"5c7c75f21a07a4f3944b5e7fdaa3f4d4a582a004","_id":"xml-formatter@2.4.1","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","_npmUser":{"name":"chrisbottin","email":"chrisbottin@gmail.com"},"dist":{"integrity":"sha512-UFnFRNum4BxicU9U4DPhIlHAQqHtT/vTdCvC6fiD78xlpug8YLgawW3MHmT1+eCAM7YomvMGZziiMz9AnExZgQ==","shasum":"20cd625ac2a1b330759ac64dc86a9de901ad2a0d","tarball":"http://registry-npm.ywwl.com/xml-formatter/download/xml-formatter-2.4.1.tgz","fileCount":6,"unpackedSize":21925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhP0c4CRA9TVsSAnZWagAA7L8P/jY6HIN1eyhV8PhJLFNY\nnVgV/TSQogFnD8oXE8Xbrlwf2IIToYLcMfuaCp7j25WYxv1xnsxqpaXI745h\nNXK9XEscCS6XIJCQkCNerH7SSTgmHF90ZHvf18W3sY1adqtTuqvYjf2+xIEi\nkq+WKx3C9UBNScbIR1BcLLID5z1iMS7xgtq+nOWqX/FTGmCt1eI2R5Mxy9wX\nk74tSBP8xP22sP7AlF1DrVZfDOFwUtCHSLEN1RDOqvOI47ObZ45elPmQr/2g\nxmzuCWv2MWWQtmr72XlgEGEP1DvSaRGo1TSPYA9qFIeonhUVZKIETBM1qySC\nsNM9Hn0AAuwDgANEYrXbp6yJBy6azO8uq3oaoGT4Uhn3GQMppA7qSR7JjC/D\nwFxpcuZZpR8G9+nRHwS1hBtn2qU4QffOs7yqaFKdqQcuhRHXHRVa28IrL5wd\nF0ziMBKUZTNSUxMnEsTsWlSg5dbK25J+vty9iLRmsMRxujcNK8NzE37W2uTe\nlMVA21GRzHKA+PaJj5VwHLoAqVc/pa2u1f4NteXqgCzBcjxnR2m/73Hhr5ol\nyJw/00m08GoAGhJue07E7g0l5+VxkoP8+FfdGz85lxfH+MH+NgNSG2zchFp8\nitj/iZcBGbwMwlBD7OGqwoQ6RcFPzD6LmgWuR3P3nDljc9Be8W4tUjBrOiGZ\ndoT7\r\n=XbFY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHnzAJgu9FZxrUkMDgSyvlix9AGKH1r+I+mOmssTvNsjAiAg/09wWRkESXqTxouoEZKHMBwDzMxdK9AqrcqTN8v4Tw=="}],"size":4998,"noattachment":false,"key":"/xml-formatter/-/xml-formatter-2.4.1.tgz"},"directories":{},"maintainers":[{"name":"chrisbottin","email":"chrisbottin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/xml-formatter_2.4.1_1631536952487_0.09744520889001351"},"_hasShrinkwrap":false,"readme":"\n# xml-formatter\n\nConverts XML into a human readable format (pretty print) while respecting the `xml:space` attribute.\n\nReciprocally, the `xml-formatter` package can minify pretty printed XML.\n\nThe `xml-formatter` package can also be used on the browser using the browserified version with a small footprint.\n\n[![Build Status](https://github.com/chrisbottin/xml-formatter/actions/workflows/ci.yml/badge.svg)](https://github.com/chrisbottin/xml-formatter/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/xml-formatter.svg)](https://npmjs.org/package/xml-formatter)\n\n## Installation\n\n```\n$ npm install xml-formatter\n```\n\n## Example\n\n### Usage:\n\n```js\nimport xmlFormat from 'xml-formatter';\n\nxmlFormat('<root><content><p xml:space=\"preserve\">This is <b>some</b> content.</content></p>');\n```\n\n### Output:\n\n```xml\n<root>\n    <content>\n        <p xml:space=\"preserve\">This is <b>some</b> content.</p>\n    </content>\n</root>\n```\n\n## Options\n\n- `filter`: Function to filter out unwanted nodes by returning `false`.\n  - type: `function(node) => boolean`\n  - default: `() => true`\n- `ignoredPaths`: List of XML element paths to ignore during formatting. \nThis can be a partial path (element tag name) or full path starting from the document element e.g. `['/html/head/script', 'pre']`.\n  - type: `string[]`\n  - default: `[]`\n- `indentation`: The value used for indentation.\n  - type: `string`\n  - default: `'    '`\n- `collapseContent`: True to keep content in the same line as the element. Only works if element contains at least one text node.\n  - type: `boolean`\n  - default: `false`\n- `lineSeparator`: Specify the line separator to use.\n  - type: `string`\n  - default: `\\r\\n`\n- `whiteSpaceAtEndOfSelfclosingTag`: True to end self-closing tags with a space e.g. `<tag />`.\n  - type: `boolean`\n  - default: `false`\n- `throwOnFailure`: Throw an error when XML fails to parse and get formatted otherwise the original XML is returned.\n  - type: `boolean`\n  - default: `true`\n- `forceSelfClosingEmptyTag`: True to force empty tags to be self-closing.\n  - type: `boolean`\n  - default: `false`\n\n### Usage:\n \n```js\nimport xmlFormat from 'xml-formatter';\n\nxmlFormat('<root><!-- content --><content><p>This is <b>some</b> content.</content></p>', {\n    indentation: '  ', \n    filter: (node) => node.type !== 'Comment', \n    collapseContent: true, \n    lineSeparator: '\\n'\n});\n\n```\n\n### Output:\n\n```xml\n<root>\n  <content>\n    <p>This is <b>some</b> content.</p>\n  </content>\n</root>\n```\n\n## Minify mode\n\n### Usage:\n\n```js\nimport xmlFormat from 'xml-formatter';\n\nconst xml = `\n<root>\n  <content>\n    <p>\n        This is <b>some</b> content.\n    </p>\n  </content>\n</root>`;\n\nxmlFormat.minify(xml, {\n    filter: (node) => node.type !== 'Comment',\n    collapseContent: true\n});\n\n```\n\n### Output:\n\n```xml\n<root><content><p>This is<b>some</b>content.</p></content></root>\n```\n\n## On The Browser\n\nThe code is transpiled using [Babel](https://babeljs.io/) with [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) default values and bundled using [browserify](https://browserify.org/).\n\n### Using `require('xml-formatter')`\n\n### Page:\n \n```html\n<script type=\"text/javascript\" src=\"dist/browser/xml-formatter.js\"></script>\n```\n\n### Usage:\n \n```js\nconst xmlFormatter = require('xml-formatter');\n\nxmlFormat('<root><content><p xml:space=\"preserve\">This is <b>some</b> content.</content></p>');\n```\n\n### Using global function `xmlFormatter`\n\n### Page:\n\n```html\n<script type=\"text/javascript\" src=\"dist/browser/xml-formatter-singleton.js\"></script>\n```\n\n### Usage:\n\n```js\nxmlFormatter('<root><content><p xml:space=\"preserve\">This is <b>some</b> content.</content></p>');\n```\n\n### Output\n\n```xml\n<root>\n    <content>\n        <p xml:space=\"preserve\">This is <b>some</b> content.</p>\n    </content>\n</root>\n```\n\n## License\n\nMIT\n","publish_time":1631536952591,"_cnpm_publish_time":1631536952591,"dist-tags":{"latest":"3.7.0","rc-minify":"3.3.0-rc-minify.0"}}