-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Is it possible to prettyprint document without adding newlines after a certain tag? #2141
Comments
Currently there's no configurable way to change this. The default for unknown tags is to parse them as blocks. I think it might make sense to parse unknown tags as "block + format-as-inline". That would prevent the line wrap when pretty-printing. Or, perhaps, try and infer it by checking if the children are defined block tags or not. |
Got it. I'll just use string replacement for now. |
I took a pass at this (particularly, attempting to introduce a rule that only indents if an element contains other elements, but not if (all the other existing rules)). But it got too gnarly, as the rule needs to be implemented differently in each of Element outerHead, Element outerTail, and TextNode outerHead. So, I'm declaring bankruptcy on the current pretty-printer implementation, and won't make other changes to it. I plan on refactoring it at some point to a strategy type object (which will provide more configurability) that will also maintain more state during the pass (a stack of what was indented, what requires white-space preservation, etc). With the goal of substantially simplifying the implementation and allowing better control, both by default and by users. But for now, yeah, string replacement is your best bet... |
I support removing pretty print as default, this feature makes lots of trouble, such as |
@anonyein I have covered this before in other issues: I prefer the pretty printer being on by default for HTML, and don't intend on changing that. It is off by default when using the XML parser, as we don't know the whitespace significance in XML. But we do in HTML and it generally appropriate and safe when serializing for downstream HTML parsers. Let's keep this issue for the specific output change noted. |
I see. THX |
|
@anonyein like I said, please keep this issue focussed on the specific issue, not general pretty-print issues. At any rate, If you read the |
I get it, using "wholeText" instead. Thanks for your help! |
I use jsoup to create epub. Here is the formatted xhtml file in the epub file. But some readers require that there should be no extra spaces or line breaks after
<dc:language>
. Is there a way to solve this?The text was updated successfully, but these errors were encountered: