Set the indent character in a more appropriate spot.

The previous location was fine when saving the output stream, but it led to
unset character when using node interrogation, which _also_ uses the pretty
printers to get text. This is a more appropriate location to set the character.

This is the first instance of our cool Swift wrapper API tester catching an
issue for us. Nice!

Proof that the automated API
This commit is contained in:
Jim Derry 2021-08-19 18:12:29 -04:00
parent 0fe913eb76
commit 1d2a183f32
2 changed files with 7 additions and 6 deletions

View file

@ -1291,6 +1291,12 @@ void TY_(AdjustConfig)( TidyDocImpl* doc )
TY_(SetOptionBool)( doc, TidyQuoteAmpersand, yes );
TY_(SetOptionBool)( doc, TidyOmitOptionalTags, no );
}
/* Setup the indent character. */
if cfgBool(doc, TidyPPrintTabs)
doc->indent_char = '\t';
else
doc->indent_char = ' ';
}

View file

@ -2253,16 +2253,11 @@ int tidyDocSaveStream( TidyDocImpl* doc, StreamOut* out )
Bool asciiChars = cfgBool(doc, TidyAsciiChars);
Bool makeBare = cfgBool(doc, TidyMakeBare);
Bool escapeCDATA = cfgBool(doc, TidyEscapeCdata);
Bool ppWithTabs = cfgBool(doc, TidyPPrintTabs);
TidyAttrSortStrategy sortAttrStrat = cfg(doc, TidySortAttributes);
TidyConfigChangeCallback callback = doc->pConfigChangeCallback;
doc->pConfigChangeCallback = NULL;
if (ppWithTabs)
doc->indent_char = '\t';
else
doc->indent_char = ' ';
if (escapeCDATA)
TY_(ConvertCDATANodes)(doc, &doc->root);