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

Feature to preserve at most n empty lines between elements #172

Closed
niwred opened this issue Dec 29, 2024 · 3 comments · Fixed by #177
Closed

Feature to preserve at most n empty lines between elements #172

niwred opened this issue Dec 29, 2024 · 3 comments · Fixed by #177

Comments

@niwred
Copy link

niwred commented Dec 29, 2024

I often add an empty line between some elements in XML-based code files to improve readability. It would be nice if the formatter could preserve up to n empty lines.
That is, if the option was set to 1, the formatter would preserve one empty line but would normalize two or more consecutive empty lines into one empty line. Maybe with an additional option to add an exception list with element names where empty lines between child elements are not allowed.

Kind Regards
Erwin

@pmahend1
Copy link
Owner

Hi @niwred

Thanks for being a user of PrettyXML and taking the time to raise a request.

  • Could you please provide more on empty lines. Do you mean empty lines between XML elements?
  • Are you expecting to enforce it between all elements irrespective what user has entered?
  • Please provide an example for more clarification.

@niwred
Copy link
Author

niwred commented Jan 1, 2025

Hi @pmahend1

PrettyXML does precisely what I need when it comes to formatting elements on one or multiple lines. However, I often need to write XML based configurations where I would like to have empty lines between some elements for grouping/clarity. My requirements would be met if PrettyXML could preserve empty lines between elements.

Better yet, if there would be an option to specify the maximum of empty lines between elements. This way, files that have two or more empty lines between elements would be normalized to one empty line.

A typical .xml config file that I have to manually maintain looks like this:

<query xmlns="http://............../query.xsd" 
             object="SoftwareSignature" 
             from="Machine" 
             multidelete="true" 
             tooltiptables="Machine,SoftwareSignature,SoftwareCategory,SoftwarePackage,MachineSoftwareSignature" 
             web="true" 
             guid="{32B8E0E3-982C-4EA9-9759-14466A676C59}">

  <description>
    <p>Show software signatues installed on a specific machine.</p>
  </description>

  <links>
    <link object="Machine" id="MachineID" />
    <link object="SoftwareSignature" id="SoftwareSignatureID" />
    <link object="SoftwarePackage" id="SoftwarePackageID" />
    <link object="SoftwarePublisher" id="SoftwarePublisherID" />
  </links>

  <weblinks>
    <link object="Machine" column="Machine" id="MachineGuid" />
    <link object="SoftwarePackage" column="SoftwarePackage" id="SoftwarePackageGuid"  />
    <link object="SoftwarePublisher" column="SoftwarePublisher" id="SoftwarePublisherGuid"  />
    <link object="SoftwareSignature" column="Signature" id="SoftwareSignatureGuid"  />
  </weblinks>

  <initially>
    <property name="condition" value="" />
  </initially>

  <dialog>  
    <input name="x" type="label" value="${machine.printablename}" align="left" />
    <input name="unassigned" type="checkbox" value="false" title="Include unassigned signatures" align="left" />
  </dialog>

  <finally>
    <property name="jointype" value="inner"/>
    <property name="jointype" value="left outer" select-if="${dialog_unassigned}" />
  </finally>

 .....
</query>

IMHO the empty lines help structure the file for easier reading/maintaining.

Kind regards

Erwin

@pmahend1
Copy link
Owner

pmahend1 commented Jan 1, 2025

Thanks for the clarification.

How about a setting to include an empty line between all elements except root element?
Or do you prefer it only for some elements instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants