@prettier/plugin-xml
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -9,2 +9,8 @@ # Changelog | ||
## [0.13.0] - 2021-01-22 | ||
### Added | ||
- Maintain newlines if there are some in the original source. | ||
## [0.12.0] - 2020-08-31 | ||
@@ -125,3 +131,6 @@ | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v0.10.0...HEAD | ||
[unreleased]: https://github.com/prettier/plugin-xml/compare/v0.13.0...HEAD | ||
[0.13.0]: https://github.com/prettier/plugin-xml/compare/v0.12.0...v0.13.0 | ||
[0.12.0]: https://github.com/prettier/plugin-xml/compare/v0.11.0...v0.12.0 | ||
[0.11.0]: https://github.com/prettier/plugin-xml/compare/v0.10.0...v0.11.0 | ||
[0.10.0]: https://github.com/prettier/plugin-xml/compare/v0.9.0...v0.10.0 | ||
@@ -128,0 +137,0 @@ [0.9.0]: https://github.com/prettier/plugin-xml/compare/v0.8.0...v0.9.0 |
{ | ||
"name": "@prettier/plugin-xml", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "prettier plugin for XML", | ||
@@ -27,3 +27,3 @@ "main": "src/plugin.js", | ||
"eslint": "^7.0.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-config-prettier": "^7.0.0", | ||
"jest": "^26.0.0" | ||
@@ -30,0 +30,0 @@ }, |
@@ -43,2 +43,4 @@ const { | ||
offset: node.startOffset, | ||
startLine: node.startLine, | ||
endLine: node.endLine, | ||
printed: node.image | ||
@@ -49,2 +51,4 @@ }); | ||
offset: node.startOffset, | ||
startLine: node.startLine, | ||
endLine: node.endLine, | ||
printed: node.image | ||
@@ -55,2 +59,4 @@ }); | ||
offset: node.location.startOffset, | ||
startLine: node.location.startLine, | ||
endLine: node.location.endLine, | ||
printed: path.call(print, "children", "chardata", index) | ||
@@ -61,2 +67,4 @@ }); | ||
offset: node.location.startOffset, | ||
startLine: node.location.startLine, | ||
endLine: node.location.endLine, | ||
printed: path.call(print, "children", "element", index) | ||
@@ -67,2 +75,4 @@ }); | ||
offset: node.startOffset, | ||
startLine: node.startLine, | ||
endLine: node.endLine, | ||
printed: node.image | ||
@@ -73,2 +83,4 @@ }); | ||
offset: node.location.startOffset, | ||
startLine: node.location.startLine, | ||
endLine: node.location.endLine, | ||
printed: (node.children.CharRef || node.children.EntityRef)[0].image | ||
@@ -300,2 +312,4 @@ }); | ||
offset: node.location.startOffset, | ||
startLine: node.location.startLine, | ||
endLine: node.location.endLine, | ||
printed: path.call( | ||
@@ -313,16 +327,32 @@ print, | ||
.concat(PROCESSING_INSTRUCTION.map(printProcessingInstruction)) | ||
.sort((left, right) => left.offset - right.offset) | ||
.map(({ printed }) => printed); | ||
.sort((left, right) => left.offset - right.offset); | ||
const separator = | ||
children.length == 1 && chardatas.length == 1 ? softline : hardline; | ||
// If the only content of this tag is chardata, then use a softline so | ||
// that we won't necessarily break (to allow <foo>bar</foo>). | ||
if (children.length === 1 && chardatas.length === 1) { | ||
return group( | ||
concat([ | ||
openTag, | ||
indent(concat([softline, children[0].printed])), | ||
softline, | ||
closeTag | ||
]) | ||
); | ||
} | ||
return group( | ||
concat([ | ||
openTag, | ||
indent(concat([separator, join(separator, children)])), | ||
separator, | ||
closeTag | ||
]) | ||
); | ||
const docs = []; | ||
let lastLine = children[0].startLine; | ||
children.forEach((node) => { | ||
if (node.startLine - lastLine >= 2) { | ||
docs.push(hardline, hardline); | ||
} else { | ||
docs.push(hardline); | ||
} | ||
docs.push(node.printed); | ||
lastLine = node.endLine; | ||
}); | ||
return group(concat([openTag, indent(concat(docs)), hardline, closeTag])); | ||
} | ||
@@ -329,0 +359,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36348
715