From 20da40d2e8c9d8ceb7168f837a9ff6c7341e884f Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sun, 14 Sep 2014 19:06:19 +0200 Subject: [PATCH] Always show DOCTYPE found --- console/tidy.c | 11 ++++++++++- include/tidy.h | 2 ++ src/tidylib.c | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/console/tidy.c b/console/tidy.c index 5457b6a..5a14e0c 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -1313,9 +1313,18 @@ int main( int argc, char** argv ) if ( status >= 0 ) status = tidyCleanAndRepair( tdoc ); - if ( status >= 0 ) + if ( status >= 0 ) { status = tidyRunDiagnostics( tdoc ); + if ( !tidyOptGetBool(tdoc, TidyQuiet) ) { + /* NOT quiet, show DOCTYPE, if not already shown */ + if (!tidyOptGetBool(tdoc, TidyShowInfo)) { + tidyOptSetBool( tdoc, TidyShowInfo, yes ); + tidyReportDoctype( tdoc ); /* FIX20140913: like warnings, errors, ALWAYS report DOCTYPE */ + tidyOptSetBool( tdoc, TidyShowInfo, no ); + } + } + } if ( status > 1 ) /* If errors, do we want to force output? */ status = ( tidyOptGetBool(tdoc, TidyForceOutput) ? status : -1 ); diff --git a/include/tidy.h b/include/tidy.h index 8d38b34..d6c68a7 100644 --- a/include/tidy.h +++ b/include/tidy.h @@ -676,6 +676,8 @@ TIDY_EXPORT int TIDY_CALL tidyCleanAndRepair( TidyDoc tdoc ); */ TIDY_EXPORT int TIDY_CALL tidyRunDiagnostics( TidyDoc tdoc ); +TIDY_EXPORT int TIDY_CALL tidyReportDoctype( TidyDoc tdoc ); + /** @} end Clean group */ diff --git a/src/tidylib.c b/src/tidylib.c index c587485..e3d9f23 100644 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -56,6 +56,7 @@ static int tidyDocParseSource( TidyDocImpl* impl, TidyInputSource* docI ** pre-or-post repair. */ static int tidyDocRunDiagnostics( TidyDocImpl* doc ); +static void tidyDocReportDoctype( TidyDocImpl* doc ); static int tidyDocCleanAndRepair( TidyDocImpl* doc ); @@ -1136,6 +1137,16 @@ int TIDY_CALL tidyRunDiagnostics( TidyDoc tdoc ) return -EINVAL; } +int TIDY_CALL tidyReportDoctype( TidyDoc tdoc ) +{ + int iret = -EINVAL; + TidyDocImpl* impl = tidyDocToImpl( tdoc ); + if ( impl ) { + tidyDocReportDoctype( impl ); + iret = 0; + } + return iret; +} /* Workhorse functions. ** @@ -1228,6 +1239,12 @@ int tidyDocRunDiagnostics( TidyDocImpl* doc ) return tidyDocStatus( doc ); } +void tidyDocReportDoctype( TidyDocImpl* doc ) +{ + TY_(ReportMarkupVersion)( doc ); +} + + /* ###################################################################################### HTML5 STUFF */