Replies: 1 comment 1 reply
-
|
Hi there, For background, @malteskoruppa proposed this in PR #1114. At that time we didn't take it in because I didn't want jsoup to take on the extra memory consumption in the DOM to track that for every attribute, for a (relatively) niche requirement. Since then, I have added a framework to optionally store arbitrary object data internally within Attributes, and that's how we include source positional tracking when enabled. So, I am more inclined to include attribute quote metadata now, using that mechanism. Can you expand on the proposal -- are you looking at only tracking the data, or also in the option to preserve it when printing? I think that's more interesting and something that would be difficult to do solely in 'user space'. If so we would need to to choose the correct quote / escaping requirement when printing. E.g. if an attribute value was originally unquoted, then changed in DOM to include a space, the output could no longer be unquoted. And once we have that, I think it would be nifty to include a minimizing quote option that would select the minimum quoting to use (regardless of the original input). E.g. the option to use no quotes if the value is just a keyword; use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve found it useful in my own work to have access to information about how attribute values are quoted in HTML, specifically, whether they use single quotes, double quotes, or are unquoted.
I’d like to suggest adding this detail to the parser. This could be helpful for tools that need to preserve the original formatting or perform source-level analysis.
I’d be happy to contribute an implementation for this feature.
Beta Was this translation helpful? Give feedback.
All reactions