diff --git a/src/lexer.c b/src/lexer.c index 8877445..479fcc9 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -100,7 +100,7 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node ) int col = ( doc->lexer ? doc->lexer->columns : 0 ); SPRTF("R=%d C=%d: ", line, col ); // DEBUG: Be able to set a TRAP on a SPECIFIC row,col - if ((line == 60) && (col == 1)) { + if ((line == 7) && (col == 1)) { check_me("Show_Node"); // just a debug trap } if (lexer && lexer->token && diff --git a/src/tags.c b/src/tags.c index a4e20ce..273ec47 100644 --- a/src/tags.c +++ b/src/tags.c @@ -734,7 +734,9 @@ void TY_(FreeDeclaredTags)( TidyDocImpl* doc, UserTagType tagType ) * Tidy defaults to HTML5 mode * If the is found to NOT be HTML5, * then adjust tags to HTML4 mode - * At present only TidyTag_A, but could apply to others + * + * NOTE: For each change added to here, there must + * be a RESET added in TY_(ResetTags) below! \*/ void TY_(AdjustTags)( TidyDocImpl *doc ) { @@ -778,6 +780,37 @@ void TY_(AdjustTags)( TidyDocImpl *doc ) } } +/*\ + * Issue #285 + * Reset the table to default HTML5 mode. + * For every change made in the above AdjustTags, + * the equivalent reset must be added here. +\*/ +void TY_(ResetTags)( TidyDocImpl *doc ) +{ + Dict *np = (Dict *)TY_(LookupTagDef)( TidyTag_A ); + TidyTagImpl* tags = &doc->tags; + if (np) + { + np->parser = TY_(ParseBlock); + np->model = (CM_INLINE|CM_BLOCK|CM_MIXED); + } + np = (Dict *)TY_(LookupTagDef)( TidyTag_CAPTION ); + if (np) + { + np->parser = TY_(ParseBlock); + } + + np = (Dict *)TY_(LookupTagDef)( TidyTag_OBJECT ); + if (np) + { + np->model = (CM_OBJECT|CM_IMG|CM_INLINE|CM_PARAM); /* reset */ + } +#if ELEMENT_HASH_LOOKUP + tagsEmptyHash( doc, tags ); /* not sure this is really required, but to be sure */ +#endif +} + void TY_(FreeTags)( TidyDocImpl* doc ) { TidyTagImpl* tags = &doc->tags; diff --git a/src/tags.h b/src/tags.h index dde330e..2412717 100644 --- a/src/tags.h +++ b/src/tags.h @@ -87,7 +87,7 @@ ctmbstr TY_(GetNextDeclaredTag)( TidyDocImpl* doc, UserTagType tagType, void TY_(InitTags)( TidyDocImpl* doc ); void TY_(FreeTags)( TidyDocImpl* doc ); void TY_(AdjustTags)( TidyDocImpl *doc ); /* if NOT HTML5 DOCTYPE, fall back to HTML4 legacy mode */ - +void TY_(ResetTags)( TidyDocImpl *doc ); /* set table to HTML5 mode */ /* Parser methods for tags */ diff --git a/src/tidylib.c b/src/tidylib.c index 15e9596..69ac014 100755 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -1185,6 +1185,7 @@ int TY_(DocParseStream)( TidyDocImpl* doc, StreamIn* in ) assert( doc->docIn == NULL ); doc->docIn = in; + TY_(ResetTags)(doc); /* reset table to html5 mode */ TY_(TakeConfigSnapshot)( doc ); /* Save config state */ TY_(FreeAnchors)( doc );