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
(bug) "--vertical-space yes" adds two blank lines instead of one #582
Comments
@shentino thank you for this issue... as you suggest, it has been around for a while... Probably even since the Note that These need to be read, reviewed to appreciate this vertical space issue... But Given a simple input: <ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul> With a config of F:\Projects\tidy-html5\build\win64>tidy5 --show-body-only yes --show-info no --vertical-space yes F:\Projects\tidy-test\test\input5\in_581.html
No warnings or errors were found.
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul> Which is perfect. A single newline is added... Now I add F:\Projects\tidy-html5\build\win64>tidy5 -i --show-body-only yes --show-info no --vertical-space yes F:\Projects\tidy-test\test\input5\in_581.html
No warnings or errors were found.
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul> So, in this case, it is the additional interaction with the That might be a clue to look for where this extra newline is added... We need to also test Appreciate any comment, patches or PR on this... thanks... |
@shentino Ok, I can sort of see where it happens... all in pprint.c module... Line 2349 does a We sort of have what we want... that is an extra newline, if classic mode... But then a little later, Line 2364, if indent: auto, that is Maybe this third newline is no longer required, and can be removed... but maybe this is not the problem... Perhaps someone will get the chance to comment out 2364 and 2365 and run some tests, and show the results... we would also need to conduct the full regression tests... thanks... |
@shentino have pushed a fix to the issue-582
As a sample test case, try in_582-1.html using config cfg_582-1.txt... As suspected, just removing lines 2364-2365 did the trick - patch - diff --git a/src/pprint.c b/src/pprint.c
index 68e8d44..87568b0 100644
--- a/src/pprint.c
+++ b/src/pprint.c
@@ -2340,7 +2340,8 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
else /* other tags */
{
Bool indcont = ( cfgAutoBool(doc, TidyIndentContent) != TidyNoState );
- Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState );
+ /* Issue #582 - Seems this is no longer used
+ Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState ); */
Bool hideend = cfgBool( doc, TidyOmitOptionalTags );
Bool classic = TidyClassicVS; /* #228 - cfgBool( doc, TidyVertSpace ); */
uint contentIndent = indent;
@@ -2360,9 +2361,11 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
* Issue #180 - with the above PCondFlushLine,
* this adds an uneccessary additional line!
* Maybe only if 'classic' ie --vertical-space yes
+ * Issue #582 - maybe this is no longer needed!
+ * It adds a 3rd newline if indent: auto...
+ * if ( indsmart && node->prev != NULL && classic)
+ * TY_(PFlushLineSmart)( doc, indent );
\*/
- if ( indsmart && node->prev != NULL && classic)
- TY_(PFlushLineSmart)( doc, indent );
/* do not omit elements with attributes */
if ( !hideend || !TY_(nodeHasCM)(node, CM_OMITST) || Have done a full regression test and it passes... Look forward to further feedback... thanks... |
I tested it and it works on my end. Please merge to mainline ASAP so my distro can pick it up. |
Issue 585 might be related. |
Issue #582 - Remove extra new line in 'classic' mode
@shentino, since @balthisar has merged PR #583, thanks, this seems to have fixed this so closing... And note you have openned #596 to cover other vertical space matters... thanks... |
I would have let the previous issue's responder report this, but the truth is I encountered it a long time ago and had since forgotten about this option.
Please see issue #581 for more details, this is a separate bugtracker
Edit: Add hash to cause cross-link of issues
The text was updated successfully, but these errors were encountered: