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

xml-beautify

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-beautify - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

18

dist/XmlBeautify.js

@@ -95,3 +95,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.XmlBeautify = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

resultXml += buildInfo.xmlText;
return resultXml;

@@ -105,4 +105,12 @@

var elementTextContent = element.textContent;
var blankReplacedElementContent = elementTextContent.replace(/ /g, '').replace(/\r?\n/g, '').replace(/\n/g, '').replace(/\t/g, '');
if (blankReplacedElementContent.length == 0) {
elementTextContent = "";
}
var elementHasNoChildren = !(element.children.length > 0);
var elementHasValueOrChildren = (element.textContent && element.textContent.length > 0);
var elementHasValueOrChildren = (elementTextContent && elementTextContent.length > 0);
var elementHasItsValue = elementHasNoChildren && elementHasValueOrChildren;

@@ -122,3 +130,7 @@ var isEmptyElement = elementHasNoChildren && !elementHasValueOrChildren;

if (elementHasItsValue) {
valueOfElement = element.textContent;
valueOfElement = elementTextContent;
}

@@ -125,0 +137,0 @@

2

package.json
{
"name": "xml-beautify",
"version": "1.0.0",
"version": "1.0.1",
"description": "XML pretty formatter that corresponds to the self-closing empty elements.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,6 +6,23 @@ # Overview

# Quick start
# How to use?
```javascript
var beautifiedXmlText = new XmlBeautify().beautify(srcXmlText,
{
indent: " ", //indent pattern like white spaces
useSelfClosingElement: true //true:use self-closing element when empty element.
});
```
# Demo
## demo on the web
https://riversun.github.io/xml-beautify/index.html
### download standalone *.js
https://github.com/riversun/xml-beautify/blob/master/dist/XmlBeautify.js
<hr>
## demo on node.js

@@ -20,3 +37,3 @@

## install via npm
### install via npm

@@ -27,16 +44,7 @@ ```shell

# How to use?
## Example
```javascript
var resultXmlText = new XmlBeautify().beautify(xmlText,
{
indent: " ", //indent pattern like white spaces
useSelfClosingElement: true //true:use self-closing element when empty element.
});
```
- source XML
[BEFORE] source XML
```XML

@@ -60,3 +68,3 @@ <?xml version="1.0" encoding="utf-8"?><example version="2.0">

- formatted XML
[AFTER] beautified XML
```XML

@@ -63,0 +71,0 @@ <?xml version="1.0" encoding="utf-8"?>

@@ -90,3 +90,3 @@ /*

resultXml += buildInfo.xmlText;
return resultXml;

@@ -100,4 +100,12 @@

var elementTextContent = element.textContent;
var blankReplacedElementContent = elementTextContent.replace(/ /g, '').replace(/\r?\n/g, '').replace(/\n/g, '').replace(/\t/g, '');
if (blankReplacedElementContent.length == 0) {
elementTextContent = "";
}
var elementHasNoChildren = !(element.children.length > 0);
var elementHasValueOrChildren = (element.textContent && element.textContent.length > 0);
var elementHasValueOrChildren = (elementTextContent && elementTextContent.length > 0);
var elementHasItsValue = elementHasNoChildren && elementHasValueOrChildren;

@@ -117,3 +125,7 @@ var isEmptyElement = elementHasNoChildren && !elementHasValueOrChildren;

if (elementHasItsValue) {
valueOfElement = element.textContent;
valueOfElement = elementTextContent;
}

@@ -120,0 +132,0 @@

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