diff --git a/CHANGELOG.md b/CHANGELOG.md index 020ca01..da7fa38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Stable +## 6.6.0: 25-Dec-2025 + +- Added [Preserve New Lines](README.md#preserve-new-lines) setting. + ## 6.5.0: 25-Dec-2025 - Changed dotnet dependency from Dotnet 8 to Dotnet 10. diff --git a/README.md b/README.md index 33d8fbe..15c86cb 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ These will be for **Prettify XML** command. | prettyxml.settings.enableLogs | false | Enables logs | | [prettyxml.settings.wildCardedExceptionsForPositionAllAttributesOnFirstLine](#wild-carded-exceptions-for-position-all-attributes-on-first-line) | Array\ | Wild card exceptions for elements to ignore positionAllAttributesOnFirstLine | | [prettyxml.settings.addEmptyLineBetweenElements](#add-empty-line-between-elements) | false | Add empty line between elements if the child count is greater than 2 | +| [prettyxml.settings.preserveNewLines](#preserve-new-lines) | false | Preserve existing new lines between elements. | ![Settings Image.](./images/settings.png) @@ -143,25 +144,25 @@ Example: Value = 2 -#### Input#1 +#### Input 1 ```xml ``` -#### Output#1 +#### Output 1 ```xml ``` -#### Input#2 +#### Input 2 ```xml ``` -#### Output#2 +#### Output 2 ```xml @@ -192,7 +193,7 @@ Example: ``` -#### Ouput +#### Ouput 3 ```xml @@ -212,7 +213,7 @@ If enabled, and child elements count is greater than 2 then adds empty line betw > [!NOTE] > Please note it wont add empty element before first element and after last element. -#### Input 1 +#### Input 4 ```xml @@ -222,7 +223,7 @@ If enabled, and child elements count is greater than 2 then adds empty line betw ``` -#### Output 1 +#### Output 4 ```xml @@ -239,6 +240,67 @@ If enabled, and child elements count is greater than 2 then adds empty line betw Adds XML declaration `` if missing. Default is `true`. +### Preserve New Lines + +Preserves existing new lines between elements. + +Example: Value = **false** + +#### Input 5 + +```xml + + Text1 + + + Text2 + + Text3 + Text4 + +``` + +#### Output 5 + +```xml + + Text1 + Text2 + Text3 + Text4 + +``` + +Example: Value = **true** + +#### Input 6 + +```xml + + Text1 + + + Text2 + + Text3 + Text4 + +``` + +#### Output 6 + +```xml + + Text1 + + + Text2 + + Text3 + Text4 + +``` + --- ## Requirements diff --git a/lib/XmlFormatter.CommandLine.deps.json b/lib/XmlFormatter.CommandLine.deps.json index 387e95f..20dfcf3 100644 --- a/lib/XmlFormatter.CommandLine.deps.json +++ b/lib/XmlFormatter.CommandLine.deps.json @@ -6,31 +6,31 @@ "compilationOptions": {}, "targets": { ".NETCoreApp,Version=v10.0": { - "XmlFormatter.CommandLine/2.0.0": { + "XmlFormatter.CommandLine/2.1.0": { "dependencies": { - "XmlFormatter": "2.0.0" + "XmlFormatter": "2.1.0" }, "runtime": { "XmlFormatter.CommandLine.dll": {} } }, - "XmlFormatter/2.0.0": { + "XmlFormatter/2.1.0": { "runtime": { "XmlFormatter.dll": { - "assemblyVersion": "2.0.0.0", - "fileVersion": "2.0.0.0" + "assemblyVersion": "2.1.0.0", + "fileVersion": "2.1.0.0" } } } } }, "libraries": { - "XmlFormatter.CommandLine/2.0.0": { + "XmlFormatter.CommandLine/2.1.0": { "type": "project", "serviceable": false, "sha512": "" }, - "XmlFormatter/2.0.0": { + "XmlFormatter/2.1.0": { "type": "project", "serviceable": false, "sha512": "" diff --git a/lib/XmlFormatter.CommandLine.dll b/lib/XmlFormatter.CommandLine.dll index 31329ca..b637a1b 100644 Binary files a/lib/XmlFormatter.CommandLine.dll and b/lib/XmlFormatter.CommandLine.dll differ diff --git a/lib/XmlFormatter.CommandLine.exe b/lib/XmlFormatter.CommandLine.exe index 64d6fbc..9ff55ec 100644 Binary files a/lib/XmlFormatter.CommandLine.exe and b/lib/XmlFormatter.CommandLine.exe differ diff --git a/lib/XmlFormatter.CommandLine.pdb b/lib/XmlFormatter.CommandLine.pdb index 33a5bb9..f799682 100644 Binary files a/lib/XmlFormatter.CommandLine.pdb and b/lib/XmlFormatter.CommandLine.pdb differ diff --git a/lib/XmlFormatter.dll b/lib/XmlFormatter.dll index 8a24159..9215855 100644 Binary files a/lib/XmlFormatter.dll and b/lib/XmlFormatter.dll differ diff --git a/lib/XmlFormatter.pdb b/lib/XmlFormatter.pdb index fd6e4a9..6d5523f 100644 Binary files a/lib/XmlFormatter.pdb and b/lib/XmlFormatter.pdb differ diff --git a/package.json b/package.json index c7d7cce..0cec132 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "readme": "https://github.com/pmahend1/PrettyXML/blob/main/README.md", "description": "XML formatter extension for Visual Studio Code. Formats XML documents just like Visual Studio.", - "version": "6.5.0", + "version": "6.6.0", "publisher": "PrateekMahendrakar", "repository": { "url": "https://github.com/pmahend1/prettyxml.git" @@ -209,6 +209,11 @@ "markdownDescription": "Add empty line between elements if element count is greater than 2. Default is *Unchecked*", "default": false }, + "prettyxml.settings.preserveNewLines": { + "type": "boolean", + "markdownDescription": "Preserve existing new lines between elements. Default is *Unchecked*", + "default": false + }, "prettyxml.settings.enableLogs": { "type": "boolean", "markdownDescription": "Enable console local logs.", diff --git a/src/constants.ts b/src/constants.ts index 8728349..4dca846 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -26,6 +26,7 @@ export const Constants = { attributesInNewlineThreshold: "attributesInNewlineThreshold", wildCardedExceptionsForPositionAllAttributesOnFirstLine: "wildCardedExceptionsForPositionAllAttributesOnFirstLine", addEmptyLineBetweenElements: "addEmptyLineBetweenElements", + preserveNewLines: "preserveNewLines", enableLogs: "enableLogs", }, diff --git a/src/formatter.ts b/src/formatter.ts index 8f16bdb..d8cd2d2 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -62,6 +62,7 @@ export class Formatter { let attributesInNewlineThreshold = prettyXmlConfig.get(Constants.Settings.attributesInNewlineThreshold); let wildCardedExceptionsForPositionAllAttributesOnFirstLine = prettyXmlConfig.get>(Constants.Settings.wildCardedExceptionsForPositionAllAttributesOnFirstLine); let addEmptyLineBetweenElements = prettyXmlConfig.get(Constants.Settings.addEmptyLineBetweenElements); + let preserveNewLines = prettyXmlConfig.get(Constants.Settings.preserveNewLines); let enableLogs = prettyXmlConfig.get(Constants.Settings.enableLogs); Logger.instance.setIsEnabled(enableLogs); @@ -82,6 +83,7 @@ export class Formatter { attributesInNewlineThreshold: attributesInNewlineThreshold, wildCardedExceptionsForPositionAllAttributesOnFirstLine: wildCardedExceptionsForPositionAllAttributesOnFirstLine, addEmptyLineBetweenElements: addEmptyLineBetweenElements, + preserveNewLines: preserveNewLines, enableLogs: enableLogs, }; diff --git a/src/settings.ts b/src/settings.ts index 492bedb..c370066 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -15,6 +15,7 @@ export interface ISettings { attributesInNewlineThreshold: number; wildCardedExceptionsForPositionAllAttributesOnFirstLine?: [string]; addEmptyLineBetweenElements: boolean; + preserveNewLines: boolean; enableLogs: boolean; } @@ -35,6 +36,7 @@ export const defaultSettings: ISettings = { attributesInNewlineThreshold: 1, wildCardedExceptionsForPositionAllAttributesOnFirstLine: undefined, addEmptyLineBetweenElements: false, + preserveNewLines: false, enableLogs: false }; @@ -55,6 +57,7 @@ export class Settings { attributesInNewlineThreshold?: number; wildCardedExceptionsForPositionAllAttributesOnFirstLine?: string[]; addEmptyLineBetweenElements?: boolean; + preserveNewLines?: boolean; enableLogs?: boolean; constructor({ @@ -74,6 +77,7 @@ export class Settings { attributesInNewlineThreshold, wildCardedExceptionsForPositionAllAttributesOnFirstLine, addEmptyLineBetweenElements, + preserveNewLines, enableLogs }: Partial = {}) { this.indentLength = indentLength ?? defaultSettings.indentLength; @@ -92,6 +96,7 @@ export class Settings { this.attributesInNewlineThreshold = attributesInNewlineThreshold ?? defaultSettings.attributesInNewlineThreshold; this.wildCardedExceptionsForPositionAllAttributesOnFirstLine = wildCardedExceptionsForPositionAllAttributesOnFirstLine; this.addEmptyLineBetweenElements = addEmptyLineBetweenElements ?? defaultSettings.addEmptyLineBetweenElements; + this.preserveNewLines = preserveNewLines ?? defaultSettings.preserveNewLines; this.enableLogs = enableLogs ?? defaultSettings.enableLogs; } }