Socket
Socket
Sign inDemoInstall

@prettier/plugin-xml

Package Overview
Dependencies
Maintainers
13
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 3.1.1 to 3.2.0

9

CHANGELOG.md

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

## [3.2.0] - 2023-08-08
### Added
- Respect `xml:space="preserve"` as an override to the `xmlWhitespaceSensitivity` option.
## [3.1.1] - 2023-07-14

@@ -226,3 +232,4 @@

[unreleased]: https://github.com/prettier/plugin-xml/compare/v3.1.1...HEAD
[unreleased]: https://github.com/prettier/plugin-xml/compare/v3.2.0...HEAD
[3.2.0]: https://github.com/prettier/plugin-xml/compare/v3.1.1...v3.2.0
[3.1.1]: https://github.com/prettier/plugin-xml/compare/v3.1.0...v3.1.1

@@ -229,0 +236,0 @@ [3.1.0]: https://github.com/prettier/plugin-xml/compare/v3.0.0...v3.1.0

4

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

@@ -31,3 +31,3 @@ "type": "module",

"eslint": "^8.5.0",
"eslint-config-prettier": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"husky": "^8.0.0",

@@ -34,0 +34,0 @@ "jest": "^29.2.1",

@@ -29,6 +29,37 @@ import * as doc from "prettier/doc";

function isWhitespaceIgnorable(node) {
const { CData, Comment, reference } = node.children;
function isWhitespaceIgnorable(opts, attributes, content) {
// If the whitespace sensitivity setting is "strict", then we can't ignore the
// whitespace.
if (opts.xmlWhitespaceSensitivity === "strict") {
return false;
}
return !CData && !reference && !hasIgnoreRanges(Comment);
// If there is an xml:space attribute set to "preserve", then we can't ignore
// the whitespace.
if (
attributes &&
attributes.some(
(attribute) =>
attribute &&
attribute.children.Name[0].image === "xml:space" &&
attribute.children.STRING[0].image.slice(1, -1) === "preserve"
)
) {
return false;
}
// If there are character data or reference nodes in the content, then we
// can't ignore the whitespace.
if (content.children.CData || content.children.reference) {
return false;
}
// If there are comments in the content and the comments are ignore ranges,
// then we can't ignore the whitespace.
if (hasIgnoreRanges(content.children.Comment)) {
return false;
}
// Otherwise we can.
return true;
}

@@ -455,6 +486,3 @@

if (
opts.xmlWhitespaceSensitivity !== "strict" &&
isWhitespaceIgnorable(content[0])
) {
if (isWhitespaceIgnorable(opts, attribute, content[0])) {
const fragments = path.call(

@@ -461,0 +489,0 @@ (childrenPath) => printElementFragments(childrenPath, opts, print),

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