Socket
Socket
Sign inDemoInstall

@prettier/plugin-xml

Package Overview
Dependencies
Maintainers
12
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prettier/plugin-xml - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

9

CHANGELOG.md

@@ -9,2 +9,8 @@ # Changelog

## [0.10.0] - 2020-07-24
### Changed
- Some better support for indenting mixed content when whitespace is set to ignore.
## [0.9.0] - 2020-07-21

@@ -96,3 +102,4 @@

[unreleased]: https://github.com/prettier/plugin-xml/compare/v0.9.0...HEAD
[unreleased]: https://github.com/prettier/plugin-xml/compare/v0.10.0...HEAD
[0.10.0]: https://github.com/prettier/plugin-xml/compare/v0.9.0...v0.10.0
[0.9.0]: https://github.com/prettier/plugin-xml/compare/v0.8.0...v0.9.0

@@ -99,0 +106,0 @@ [0.8.0]: https://github.com/prettier/plugin-xml/compare/v0.7.2...v0.8.0

2

package.json
{
"name": "@prettier/plugin-xml",
"version": "0.9.0",
"version": "0.10.0",
"description": "prettier plugin for XML",

@@ -5,0 +5,0 @@ "main": "src/plugin.js",

const {
concat,
fill,
group,

@@ -34,12 +35,6 @@ hardline,

const elementOnly = (node) => {
const { CData, Comment, chardata, element, reference } = node.children;
const whitespaceIgnorable = (node) => {
const { CData, Comment, reference } = node.children;
return (
!CData &&
(!chardata || chardata.every((datum) => !datum.children.TEXT)) &&
element &&
!reference &&
!hasIgnoreRanges(Comment)
);
return !CData && !reference && !hasIgnoreRanges(Comment);
};

@@ -256,13 +251,43 @@

// If we're ignoring whitespace and we're printing a node that only contains
// other elements, then we can just print out the child elements directly.
if (opts.xmlWhitespaceSensitivity === "ignore" && elementOnly(content[0])) {
if (
opts.xmlWhitespaceSensitivity === "ignore" &&
whitespaceIgnorable(content[0])
) {
const {
Comment = [],
element,
chardata = [],
element = [],
PROCESSING_INSTRUCTION = []
} = content[0].children;
const chardatas = [];
chardata.forEach((chardatum) => {
if (chardatum.children.TEXT) {
const content = chardatum.children.TEXT[0].image.trim();
const printed = group(
concat(
content.split(/(\n)/g).map((value) => {
if (value === "\n") {
return literalline;
}
return fill(
value
.split(/( )/g)
.map((segment, index) => (index % 2 === 0 ? segment : line))
);
})
)
);
chardatas.push({
offset: chardatum.location.startOffset,
printed
});
}
});
const children = []
.concat(Comment.map(printComment))
.concat(chardatas)
.concat(

@@ -286,7 +311,10 @@ element.map((node, index) => ({

const separator =
children.length == 1 && chardatas.length == 1 ? softline : hardline;
return group(
concat([
openTag,
indent(concat([hardline, join(hardline, children)])),
hardline,
indent(concat([separator, join(separator, children)])),
separator,
closeTag

@@ -293,0 +321,0 @@ ])

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