Added methods for deleteing nodes and/or attributes.

This is useful when e.g. writing an HTML cleaner.
This commit is contained in:
Folkert van Heusden 2015-07-12 18:34:35 +00:00
parent f450263d43
commit 784c7d7f79
2 changed files with 22 additions and 0 deletions

View file

@ -823,6 +823,9 @@ TIDY_EXPORT TidyNode TIDY_CALL tidyGetHtml( TidyDoc tdoc );
TIDY_EXPORT TidyNode TIDY_CALL tidyGetHead( TidyDoc tdoc );
TIDY_EXPORT TidyNode TIDY_CALL tidyGetBody( TidyDoc tdoc );
/* remove a node */
TIDY_EXPORT TidyNode TIDY_CALL tidyDiscardElement( TidyDoc tdoc, TidyNode tnod );
/* parent / child */
TIDY_EXPORT TidyNode TIDY_CALL tidyGetParent( TidyNode tnod );
TIDY_EXPORT TidyNode TIDY_CALL tidyGetChild( TidyNode tnod );
@ -844,6 +847,8 @@ TIDY_EXPORT TidyAttr TIDY_CALL tidyAttrNext( TidyAttr tattr );
TIDY_EXPORT ctmbstr TIDY_CALL tidyAttrName( TidyAttr tattr );
TIDY_EXPORT ctmbstr TIDY_CALL tidyAttrValue( TidyAttr tattr );
TIDY_EXPORT void TIDY_CALL tidyAttrDiscard( TidyDoc itdoc, TidyNode tnod, TidyAttr tattr );
/* Null for pure HTML
TIDY_EXPORT ctmbstr tidyAttrNsLocal( TidyAttr tattr );
TIDY_EXPORT ctmbstr tidyAttrNsPrefix( TidyAttr tattr );

View file

@ -1924,6 +1924,15 @@ TidyNode TIDY_CALL tidyGetChild( TidyNode tnod )
return tidyImplToNode( nimp->content );
}
/* remove a node */
TidyNode TIDY_CALL tidyDiscardElement( TidyDoc tdoc, TidyNode tnod )
{
TidyDocImpl* doc = tidyDocToImpl( tdoc );
Node* nimp = tidyNodeToImpl( tnod );
Node* next = TY_(DiscardElement)( doc, nimp );
return tidyImplToNode( next );
}
/* siblings */
TidyNode TIDY_CALL tidyGetNext( TidyNode tnod )
{
@ -2135,6 +2144,14 @@ ctmbstr TIDY_CALL tidyAttrValue( TidyAttr tattr )
return aval;
}
void TIDY_CALL tidyAttrDiscard( TidyDoc tdoc, TidyNode tnod, TidyAttr tattr )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
Node* nimp = tidyNodeToImpl( tnod );
AttVal* attval = tidyAttrToImpl( tattr );
TY_(RemoveAttribute)( impl, nimp, attval );
}
/* Null for pure HTML
ctmbstr tidyAttrNsLocal( TidyAttr tattr )
{