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

Extra blank lines in generated / updated pom.xml #79

Closed
nosaku opened this issue Aug 21, 2022 · 10 comments
Closed

Extra blank lines in generated / updated pom.xml #79

nosaku opened this issue Aug 21, 2022 · 10 comments

Comments

@nosaku
Copy link
Contributor

nosaku commented Aug 21, 2022

When generating the pom.xml or updating (like when adding a new library with existing project as dependency), extra blank lines are added after each line. Can these blank lines be removed so I can try to preserve the formatting as close as possible?

@nosaku
Copy link
Contributor Author

nosaku commented Aug 21, 2022

I think the xmldoc toString adds the extra new lines... if we compress toString and then again do a toString it may work... here is my try:

var xmldoc = require('xmldoc');

var xmlString =
`<suggestions>
  <book title="Twilight"/>
  <book title="Twister"/>
</suggestions>`;
var originalXmlText = new xmldoc.XmlDocument(xmlString);
console.log('original:', originalXmlText.toString());
var doubleCompressXmlText = new xmldoc.XmlDocument(new xmldoc.XmlDocument(xmlString).toString({ compressed: true }));
console.log('double xmldoc:', doubleCompressXmlText.toString());

@khalilou88
Copy link
Owner

Hi @nosaku , thanks I agree this is somthing we can improve.
Please create a Pull Request and i will merge it to remove this extras lines

@khalilou88
Copy link
Owner

khalilou88 commented Aug 22, 2022

I made a test and toString({ compressed: true }) work will because @prettier/plugin-xml format the xml file after.
we need to add again the first line <?xml version="1.0" encoding="UTF-8"?> because xmldoc remove it.
Also we need to remove extra blank line from the xml templates
here the issue in xmldoc repo : nfarina/xmldoc#60

@nosaku
Copy link
Contributor Author

nosaku commented Aug 22, 2022

I made a test and toString({ compressed: true }) work will because @prettier/plugin-xml format the xml file after. we need to add again the first line <?xml version="1.0" encoding="UTF-8"?> because xmldoc remove it. Also we need to remove extra blank line from the xml templates here the issue in xmldoc repo : nfarina/xmldoc#60

Ok great thanks... shall I create a pull request and try?

@khalilou88
Copy link
Owner

@nosaku yes please

@nosaku
Copy link
Contributor Author

nosaku commented Aug 22, 2022

@khalilou88 I have made changes in my fork... can you please check once and let me know?
https://github.com/nosaku/jnxplus/tree/feature/xmldoc-changes

@khalilou88
Copy link
Owner

@nosaku Thanks, I run the code on local using a e2e test and the result is much better.
Please create a PR and I will merge it, then I will publish a new version

@nosaku
Copy link
Contributor Author

nosaku commented Aug 23, 2022

@khalilou88 Thank you... created the PR.

@khalilou88
Copy link
Owner

@nosaku the version @jnxplus/[email protected] contain your contribution. Thanks for your help.
If you have another request don't hesitate to open another issue

@nosaku
Copy link
Contributor Author

nosaku commented Aug 23, 2022

Great... thank you @khalilou88

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

No branches or pull requests

2 participants