Issue #285 - Add a ResetTags func to erset html5 mode before each document

This commit is contained in:
Geoff McLane 2015-10-14 16:55:35 +02:00
parent 55060018b3
commit d75c82275d
4 changed files with 37 additions and 3 deletions

View file

@ -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 &&

View file

@ -734,7 +734,9 @@ void TY_(FreeDeclaredTags)( TidyDocImpl* doc, UserTagType tagType )
* Tidy defaults to HTML5 mode
* If the <!DOCTYPE ...> 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;

View file

@ -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 */

View file

@ -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 );