From 7f0d5c31e6b6fa9f5426a669f3fd246218f5f607 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Mon, 1 Feb 2016 19:44:30 +0100 Subject: [PATCH] If no doctype, allow user doctype to reset table - Issue #342 --- src/parser.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/parser.c b/src/parser.c index 04ed999..4d9d67d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -4743,12 +4743,21 @@ void TY_(ParseDocument)(TidyDocImpl* doc) /*\ * #72, avoid MISSING_DOCTYPE if show-body-only. * #191, also if --doctype omit, that is TidyDoctypeOmit + * #342, adjust tags to html4-- if not 'auto' or 'html5' \*/ - if (!TY_(FindDocType)(doc) && !showingBodyOnly(doc)) + if (!TY_(FindDocType)(doc)) { ulong dtmode = cfg( doc, TidyDoctypeMode ); - if (dtmode != TidyDoctypeOmit) + if ((dtmode != TidyDoctypeOmit) && !showingBodyOnly(doc)) TY_(ReportError)(doc, NULL, NULL, MISSING_DOCTYPE); + if ((dtmode != TidyDoctypeAuto) && (dtmode != TidyDoctypeHtml5)) + { + /*\ + * Issue #342 - if not doctype 'auto', or 'html5' + * then reset mode htm4-- parsing + \*/ + TY_(AdjustTags)(doc); /* Dynamically modify the tags table to html4-- mode */ + } } TY_(InsertNodeAtEnd)( &doc->root, html); TY_(ParseHTML)( doc, html, IgnoreWhitespace );