kristian / minify-xml

Fast XML minifier / compressor / uglifier with a command-line
Other
17 stars 5 forks source link

Removing comments will leave empty space between tags #8

Closed Chris2011 closed 4 years ago

Chris2011 commented 4 years ago

I tried the latest version 2.3.1 and used it like this:

minify-xml foo.xml -o foo.min.xml --remove-whitespace-between-tags true

This is my input file: https://pastebin.com/Dighb1Ek and this is my output file: https://pastebin.com/wLEr6w79

As you can see, it was minified, and the comments were removed, but the problem is that the space is still there. So I thought the flag --remove-whitespace-between-tags true will fix this but no. Did I miss a flag for this?

Chris2011 commented 4 years ago

I expected this output:

<?xml version="1.0" encoding="UTF-8"?><project name="org.chrisle.netbeans.plugins.adobeextensionbuilder" default="netbeans" basedir="."><description>Builds, tests, and runs the project org.chrisle.netbeans.plugins.adobeextensionbuilder.</description><import file="nbproject/build-impl.xml"/></project>

kristian commented 4 years ago

Hey @Chris2011, good catch! The XML prolog is (rightfully) NOT considered a tag by minify-xml. Thus it is not minified, but I can see why the removeWhitespaceBetweenTags option is supposed to be removing that space as well! I'll have to add some special logic for optimizing the prolog and document type! Let me do that tomorrow!

Chris2011 commented 4 years ago

I understand, you are right. It is just not a "normal" tag somehow :).

kristian commented 4 years ago

This one was considerably harder to fix than I expected. 👍 Done with 2.4.0. Prolog & document type declaration will now also be minified. removeWhitespaceBetweenTags now has three possible values:

Chris2011 commented 4 years ago

Great, thx will test it soon :)