Skip to content

leafTag is unused in PrettyPrinter.scala #46

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

Closed
carlpoole opened this issue Jan 10, 2015 · 12 comments
Closed

leafTag is unused in PrettyPrinter.scala #46

carlpoole opened this issue Jan 10, 2015 · 12 comments

Comments

@carlpoole
Copy link

Was formatting an XML file and noticed that the PrettyPrinter adds closing XML tags to leaf tags instead of retaining it's correct '/>' format. It looks like the class does contain a leafTag function but does not use it.

Issue and potential fix outlined here: http://stackoverflow.com/questions/6044883/scala-xml-prettyprinter-to-format-shorter-node-when-there-is-no-text-in-it

@ashawley
Copy link
Member

Interesting about the unused leafTag function. The handling of empty elements is not exclusively a pretty-printer thing. The library generally preserves whether a closed tag or a self-closed tag was used:

scala> <node></node>.minimizeEmpty
res0: Boolean = false

scala> <node/>.minimizeEmpty
res1: Boolean = true

It seems that the Pretty-printer has inherited this behavior from the standard writer for at least the last 10 years.

I guess this raises, "What is the definition of 'pretty-printing' with respect to empty elements?" Are they preserved or not? I suppose this should be configurable in a pretty-printer at the very least.

ashawley added a commit to ashawley/scala-xml that referenced this issue Jan 23, 2015
@biswanaths
Copy link
Contributor

Previous discussion on this http://comments.gmane.org/gmane.comp.lang.scala.xml/44 . Also what do other prettyprint ( different tool, language) do ? I.e. do they print or ?

@SethTisue
Copy link
Member

Sure seems like a bug to me.

@ashawley
Copy link
Member

I made a commit in #90 that adds a Boolean parameter to PrettyPrinter that configures whether to minimize empty tags or not.

@biswanaths
Copy link
Contributor

Checking why the build is failing.

@ashawley
Copy link
Member

Thanks @biswanaths! Turns out typesafehub/migration-manager checks for binary compatibility issues. I don't have access to openjdk6, but I can try to use an Oracle 6 JDK and see if I can avoid the error.

> mimaReportBinaryIssues
[warn] Credentials file /Users/aaronhawley/.ivy2/.credentials does not exist
[info] Resolving org.scala-lang#scala-library;2.11.7 ...
[info] scala-xml: found 1 potential binary incompatibilities
[error]  * method this(Int,Int)Unit in class scala.xml.PrettyPrinter does not have a correspondent in new version
[error]    filter with: ProblemFilters.exclude[MissingMethodProblem]("scala.xml.PrettyPrinter.this")
[trace] Stack trace suppressed: run last *:mimaReportBinaryIssues for the full output.
[error] (*:mimaReportBinaryIssues) scala-xml: Binary compatibility check failed!
[error] Total time: 2 s, completed Feb 10, 2016 10:59:35 AM

@ashawley
Copy link
Member

The optional argument of minimizeEmpty for the class's constructor that I introduced has been unrolled instead to an alternate constructor method. Doing this seemed to quell the migration-manager error seen with the openjdk6 build in Travis.

ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 22, 2016
ashawley added a commit to ashawley/scala-xml that referenced this issue Jun 12, 2016
ashawley added a commit to ashawley/scala-xml that referenced this issue Sep 20, 2016
ashawley added a commit to ashawley/scala-xml that referenced this issue Oct 18, 2016
ashawley added a commit to ashawley/scala-xml that referenced this issue Dec 1, 2016
ashawley added a commit to ashawley/scala-xml that referenced this issue Feb 4, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Feb 7, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Feb 15, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 25, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 26, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 26, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 28, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue Apr 28, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue May 5, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue May 6, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue May 12, 2017
ashawley added a commit to ashawley/scala-xml that referenced this issue May 24, 2017
@ashawley
Copy link
Member

Merging #90, then the PrettyPrinter will have a minimizeEmpty argument, that is set to false. I suppose that fixes this issue? After this fix is released, we can update the StackOverflow post. :)

@ashawley ashawley mentioned this issue Oct 9, 2017
3 tasks
@ashawley
Copy link
Member

This fix was released in 1.1.0 today, and I've updated the information on the stackoverflow post. Thanks for reporting this issue.

@SethTisue
Copy link
Member

@ashawley #90 was merged, should this be closed?

@SethTisue
Copy link
Member

haha jinx

@carlpoole
Copy link
Author

Thank you!

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

4 participants