From c331917c311d5060510159f6f899f540b195786b Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Wed, 14 Mar 2012 19:38:18 +0900 Subject: [PATCH] Make the doctype handling work the way it should. --- src/lexer.c | 17 +++++++++-------- src/lexer.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lexer.c b/src/lexer.c index 8d111a4..a595639 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -119,9 +119,8 @@ int TY_(HTMLVersion)(TidyDocImpl* doc) !cfgBool(doc, TidyHtmlOut); Bool html4 = dtmode == TidyDoctypeStrict || dtmode == TidyDoctypeLoose || VERS_FROM40 & dtver; - // don't mess with - if (HT50) return HT50; - if (XH50) return XH50; + if (xhtml && dtver == VERS_UNKNOWN) return XH50; + if (dtver == VERS_UNKNOWN) return HT50; for (i = 0; W3C_Doctypes[i].name; ++i) { @@ -1552,6 +1551,8 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc ) TidyDoctypeModes dtmode = (TidyDoctypeModes)cfg(doc, TidyDoctypeMode); ctmbstr pub = "PUBLIC"; ctmbstr sys = "SYSTEM"; + Bool xhtml = (cfgBool(doc, TidyXmlOut) || doc->lexer->isvoyager) && + !cfgBool(doc, TidyHtmlOut); lexer->versionEmitted = TY_(ApparentVersion)( doc ); @@ -1595,7 +1596,11 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc ) TY_(RepairAttrValue)(doc, doctype, sys, ""); break; case TidyDoctypeAuto: - if (lexer->versions & XH11 && lexer->doctype == XH11) + if (xhtml && lexer->doctype == VERS_UNKNOWN) { + lexer->versionEmitted = XH50; + return yes; + } + else if (lexer->versions & XH11 && lexer->doctype == XH11) { if (!TY_(GetAttrByName)(doctype, sys)) TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(XH11)); @@ -1633,10 +1638,6 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc ) TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(X10T)); lexer->versionEmitted = X10T; } - else if (lexer->versions & XH50) - { - lexer->versionEmitted = XH50; - } else { if (doctype) diff --git a/src/lexer.h b/src/lexer.h index d4d2958..616b1c2 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -194,7 +194,7 @@ typedef enum /* special flag */ #define VERS_XML 65536u -/* "HTML5" */ +/* HTML5 */ #define HT50 131072u #define XH50 262144u