From 1d2a183f32cfefc4d7b19d564a5f63d6726c992f Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Thu, 19 Aug 2021 18:12:29 -0400 Subject: [PATCH] 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 --- src/config.c | 6 ++++++ src/tidylib.c | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/config.c b/src/config.c index 4a132f5..09c1f5f 100644 --- a/src/config.c +++ b/src/config.c @@ -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 = ' '; } diff --git a/src/tidylib.c b/src/tidylib.c index 4b7dfcb..d88cd9f 100644 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -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);