Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xml-formatter

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-formatter - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

.idea/xml-formatter.iml

17

index.js
function newLine(output) {
output.content += '\n';
output.content += '\r\n';
var i;

@@ -48,2 +48,13 @@ for (i = 0; i < output.level; i++) {

if (!nodePreserveSpace && output.options.collapseContent) {
var containsTextNodes = node.children.some(function(child) {
return child.name === '#text';
});
if (containsTextNodes) {
nodePreserveSpace = true;
}
}
node.children.forEach(function(child) {

@@ -85,2 +96,3 @@ processNode(child, output, preserveSpace || nodePreserveSpace);

* @config {Boolean} [stripComments=false] True to strip the comments
* @config {Boolean} [collapseContent=false] True to keep content in the same line as the element. Only works if element contains at least one text node
* @returns {string}

@@ -94,2 +106,3 @@ */

options.stripComments = options.stripComments === true;
options.collapseContent = options.collapseContent === true;

@@ -116,2 +129,2 @@ var parse = require('xml-parser-xo');

module.exports = format;
module.exports = format;

2

package.json
{
"name": "xml-formatter",
"version": "1.0.1",
"version": "1.1.0",
"repository": "chrisbottin/xml-formatter",

@@ -5,0 +5,0 @@ "description": "Converts XML into a human readable format (pretty print) while respecting the xml:space attribute",

@@ -24,3 +24,3 @@

var format = require('xml-formatter');
var xml = '<root><!-- content --><content><p xml:space="preserve">This is <b>some</b> content.</content></p>';
var xml = '<root>content><p xml:space="preserve">This is <b>some</b> content.</content></p>';

@@ -35,3 +35,2 @@ var formattedXml = format(xml);

<root>
<!-- test -->
<content>

@@ -49,5 +48,5 @@ <p xml:space="preserve">This is <b>some</b> content.</p>

var format = require('xml-formatter');
var xml = '<root><!-- content --><content><p xml:space="preserve">This is <b>some</b> content.</content></p>';
var xml = '<root><!-- content --><content><p>This is <b>some</b> content.</content></p>';
var options = {indentation: ' ', stripComments: true};
var options = {indentation: ' ', stripComments: true, collapseContent: true};
var formattedXml = format(xml, options);

@@ -63,3 +62,3 @@

<content>
<p xml:space="preserve">This is <b>some</b> content.</p>
<p>This is <b>some</b> content.</p>
</content>

@@ -72,2 +71,3 @@ </root>

- `debug` (Boolean, default=`false`) Displays a tree of the parsed XML before formatting.
- `collapseContent` (Boolean, default=`false`] True to keep content in the same line as the element. Only works if element contains at least one text node

@@ -74,0 +74,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc