Is #692 - Add a 'CleanHead' service
This commit is contained in:
parent
3843cdc3aa
commit
8d5ff2c514
31
src/clean.c
31
src/clean.c
|
@ -2780,6 +2780,37 @@ void TY_(CleanStyle)(TidyDocImpl* doc, Node *html)
|
||||||
/* ==================================================
|
/* ==================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CleanHead - clean the head node, if it exists, and we
|
||||||
|
* are going to show it in the output.
|
||||||
|
* Issue #692 - Remove multiple title elements
|
||||||
|
*/
|
||||||
|
void TY_(CleanHead)(TidyDocImpl* doc)
|
||||||
|
{
|
||||||
|
Node *head, *node, *next;
|
||||||
|
uint titles = 0;
|
||||||
|
if (cfgAutoBool(doc, TidyBodyOnly) == TidyYesState)
|
||||||
|
return; /* not going to show head, so forget it */
|
||||||
|
head = TY_(FindHEAD)(doc);
|
||||||
|
if (!head)
|
||||||
|
return;
|
||||||
|
node = head->content;
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
next = node->next; /* get any 'next' */
|
||||||
|
if (nodeIsTITLE(node))
|
||||||
|
{
|
||||||
|
titles++;
|
||||||
|
if (titles > 1)
|
||||||
|
{
|
||||||
|
TY_(Report)(doc, head, node, DISCARDING_UNEXPECTED);
|
||||||
|
TY_(DiscardElement)(doc, node); /* delete this node */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* local variables:
|
* local variables:
|
||||||
* mode: c
|
* mode: c
|
||||||
|
|
|
@ -75,5 +75,8 @@ void TY_(FixLanguageInformation)(TidyDocImpl* doc, Node* node, Bool wantXmlLang,
|
||||||
|
|
||||||
/* Issue #567 - move style elements from body to head */
|
/* Issue #567 - move style elements from body to head */
|
||||||
void TY_(CleanStyle)(TidyDocImpl* doc, Node *html);
|
void TY_(CleanStyle)(TidyDocImpl* doc, Node *html);
|
||||||
|
/* Issue #692 - discard multiple titles */
|
||||||
|
void TY_(CleanHead)(TidyDocImpl* doc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __CLEAN_H__ */
|
#endif /* __CLEAN_H__ */
|
||||||
|
|
|
@ -2153,6 +2153,8 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TY_(CleanHead)(doc); /* Is #692 - discard multiple <title> tags */
|
||||||
|
|
||||||
#if defined(ENABLE_DEBUG_LOG)
|
#if defined(ENABLE_DEBUG_LOG)
|
||||||
SPRTF("All nodes AFTER clean and repair\n");
|
SPRTF("All nodes AFTER clean and repair\n");
|
||||||
dbg_show_all_nodes( doc, &doc->root, 0 );
|
dbg_show_all_nodes( doc, &doc->root, 0 );
|
||||||
|
|
Loading…
Reference in a new issue