Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting for adding empty line between elements #177

Merged
merged 8 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 41 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
name: Deploy CI

on:
push:
branches:
- main
workflow_dispatch:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 22

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install vsce and open vsx
run: |
npm install -g @vscode/vsce
npm install -g ovsx

- name: pnpm
run: pnpm install

- name: VSCE Publish
run: vsce publish --no-dependencies -p $env:VSCE_PAT
env:
VSCE_PAT: ${{ secrets.VSCE_PRETTYXML }}

- name: Open VSX Publish
run: npx ovsx publish -p $env:OPEN_VSX_PAT
env:
OPEN_VSX_PAT: ${{ secrets.OPENVSX }}
deploy:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 22

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install vsce and open vsx
run: |
npm install -g @vscode/vsce
npm install -g ovsx

- name: pnpm
run: pnpm install

- name: VSCE Publish
id: vsce
run: |
vsce publish --no-dependencies -p $env:VSCE_PAT
$VsixName = Get-ChildItem -Filter *.vsix | Select-Object -First 1 -ExpandProperty Name
"VSIX_FILENAME=$VsixName" >> $env:GITHUB_OUTPUT
env:
VSCE_PAT: ${{ secrets.VSCE_PRETTYXML }}

- name: Open VSX Publish
run: npx ovsx publish ${{ steps.vsce.outputs.VSIX_FILENAME }} -p $env:OPEN_VSX_PAT
env:
OPEN_VSX_PAT: ${{ secrets.OPENVSX }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Stable

## 5.3.0: 20-Feb-2025

- Added feature [Add empty line between elements if elements count is greater than 2](https://github.com/pmahend1/PrettyXML/issues/172)
- Package updates to latest.

## 5.2.0: 26-Dec-2024

- Added feature [Allow the user to specify which elements have attributes on separate lines](https://github.com/pmahend1/PrettyXML/issues/162)
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ These will be for **Prettify XML** command.
| [prettyxml.settings.attributesInNewlineThreshold](#attributes-in-newline-threshold) | 1 | Attributes count threshold to position attributes in newlines. |
| prettyxml.settings.enableLogs | false | Enables logs |
| [prettyxml.settings.wildCardedExceptionsForPositionAllAttributesOnFirstLine](#wild-carded-exceptions-for-position-all-attributes-on-first-line) | Array\<string\> | 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 |

![Settings Image.](./images/settings.png)

Expand Down Expand Up @@ -193,6 +194,35 @@ Example:
</View>
```

### Add Empty Line Between Elements

If enabled, and child elements count is greater than 2 then adds empty line between elements.

> [!NOTE]
> Please note it wont add empty element before first element and after last element.

#### Input 1

```xml
<Root>
<Element1>Text1</Element1>
<Element2>Text2</Element2>
<Element3>Text3</Element3>
</Root>
```

#### Output 1

```xml
<Root>
<Element1>Text1</Element1>

<Element2>Text2</Element2>

<Element3>Text3</Element3>
</Root>
```

---

## Requirements
Expand Down
Binary file modified images/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/XmlFormatter.CommandLine.dll
Binary file not shown.
Binary file modified lib/XmlFormatter.CommandLine.exe
Binary file not shown.
Binary file modified lib/XmlFormatter.CommandLine.pdb
Binary file not shown.
Binary file modified lib/XmlFormatter.dll
Binary file not shown.
Binary file modified lib/XmlFormatter.pdb
Binary file not shown.
31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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": "5.2.0",
"version": "5.3.0",
"publisher": "PrateekMahendrakar",
"repository": {
"url": "https://github.com/pmahend1/prettyxml.git"
Expand Down Expand Up @@ -34,7 +34,7 @@
"formatter"
],
"engines": {
"vscode": "^1.96.0"
"vscode": "^1.97.0"
},
"categories": [
"Formatters"
Expand Down Expand Up @@ -196,6 +196,11 @@
],
"markdownDescription": "Attributes count threshold to position attributes in newlines. Default is *1*. This setting only works when **Position first attribute on same line** is enabled.\n\nFor example if threshold=2, all attributes will be on same line if an element has only 2 attributes,\n\notherwise each attribute will be placed on newline.\n\nMore Info: [GitHub](https://github.com/pmahend1/PrettyXML?tab=readme-ov-file#attributes-in-newline-threshold)"
},
"prettyxml.settings.addEmptyLineBetweenElements": {
"type": "boolean",
"markdownDescription": "Add empty line between elements if element count is greater than 2. Default is *Unchecked*",
"default": false
},
"prettyxml.settings.enableLogs": {
"type": "boolean",
"markdownDescription": "Enable console local logs.",
Expand All @@ -217,18 +222,18 @@
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.2",
"@types/vscode": "^1.96.0",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "8.18.2",
"@types/node": "^22.13.4",
"@types/vscode": "^1.97.0",
"@typescript-eslint/eslint-plugin": "^8.24.1",
"@typescript-eslint/parser": "8.24.1",
"@vscode/test-electron": "^2.4.1",
"esbuild": "^0.24.2",
"eslint": "^9.17.0",
"glob": "^11.0.0",
"mocha": "^11.0.1",
"ts-loader": "^9.5.1",
"typescript": "^5.7.2",
"webpack": "^5.97.1",
"esbuild": "^0.25.0",
"eslint": "^9.20.1",
"glob": "^11.0.1",
"mocha": "^11.1.0",
"ts-loader": "^9.5.2",
"typescript": "^5.7.3",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1"
},
"dependencies": {
Expand Down
Loading
Loading