/* find style,lang,class on a html file && append o a list && and end remove....*/
{
QString prehtml
= TidyCleanhtml
(body
);
/* base clean to stay on minimal standard xhtml and capable to find .... */ notneed.clear();
///////////////width="456" lang class
QRegExp expression
( "width=[\"\'](.*)[\"\']", Qt
::CaseInsensitive );
/* table td tr width image amen */ QRegExp expression2
( "style=[\"\'](.*)[\"\']", Qt
::CaseInsensitive );
QRegExp expression3
( "lang=[\"\'](.*)[\"\']", Qt
::CaseInsensitive );
QRegExp expression4
( "class=[\"\'](.*)[\"\']", Qt
::CaseInsensitive );
expression.setMinimal(true);
expression2.setMinimal(true);
expression3.setMinimal(true);
expression4.setMinimal(true);
int iPosition = 0;
while( (iPosition = expression.indexIn( prehtml , iPosition )) != -1 ) {
QString semi1
= expression.
cap( 1 );
notneed.
append(QString("width=\"%1\"").
arg(semi1
));
notneed.
append(QString("width='%1'").
arg(semi1
));
iPosition += expression.matchedLength();
}
iPosition = 0;
while( (iPosition = expression2.indexIn( prehtml , iPosition )) != -1 ) {
QString semi2
= expression2.
cap( 1 );
notneed.
append(QString("style=\"%1\"").
arg(semi2
));
notneed.
append(QString("style='%1'").
arg(semi2
));
iPosition += expression2.matchedLength();
}
iPosition = 0;
while( (iPosition = expression3.indexIn( prehtml , iPosition )) != -1 ) {
QString semi3
= expression3.
cap( 1 );
notneed.
append(QString("lang=\"%1\"").
arg(semi3
));
notneed.
append(QString("lang='%1'").
arg(semi3
));
iPosition += expression3.matchedLength();
}
iPosition = 0;
while( (iPosition = expression4.indexIn( prehtml , iPosition )) != -1 ) {
QString semi4
= expression4.
cap( 1 );
notneed.
append(QString("class=\"%1\"").
arg(semi4
));
notneed.
append(QString("class='%1'").
arg(semi4
));
iPosition += expression4.matchedLength();
}
for (int i = 0; i < notneed.size(); ++i) {
const QString fluteremove
= notneed.
at(i
);
prehtml = prehtml.replace(fluteremove,"", Qt::CaseInsensitive );
}
return prehtml;
}
/* find style,lang,class on a html file && append o a list && and end remove....*/
QString TidyExternalHtml( QString body )
{
QString prehtml = TidyCleanhtml(body); /* base clean to stay on minimal standard xhtml and capable to find .... */
QStringList notneed;
notneed.clear();
///////////////width="456" lang class
QRegExp expression( "width=[\"\'](.*)[\"\']", Qt::CaseInsensitive ); /* table td tr width image amen */
QRegExp expression2( "style=[\"\'](.*)[\"\']", Qt::CaseInsensitive );
QRegExp expression3( "lang=[\"\'](.*)[\"\']", Qt::CaseInsensitive );
QRegExp expression4( "class=[\"\'](.*)[\"\']", Qt::CaseInsensitive );
expression.setMinimal(true);
expression2.setMinimal(true);
expression3.setMinimal(true);
expression4.setMinimal(true);
int iPosition = 0;
while( (iPosition = expression.indexIn( prehtml , iPosition )) != -1 ) {
QString semi1 = expression.cap( 1 );
notneed.append(QString("width=\"%1\"").arg(semi1));
notneed.append(QString("width='%1'").arg(semi1));
iPosition += expression.matchedLength();
}
iPosition = 0;
while( (iPosition = expression2.indexIn( prehtml , iPosition )) != -1 ) {
QString semi2 = expression2.cap( 1 );
notneed.append(QString("style=\"%1\"").arg(semi2));
notneed.append(QString("style='%1'").arg(semi2));
iPosition += expression2.matchedLength();
}
iPosition = 0;
while( (iPosition = expression3.indexIn( prehtml , iPosition )) != -1 ) {
QString semi3 = expression3.cap( 1 );
notneed.append(QString("lang=\"%1\"").arg(semi3));
notneed.append(QString("lang='%1'").arg(semi3));
iPosition += expression3.matchedLength();
}
iPosition = 0;
while( (iPosition = expression4.indexIn( prehtml , iPosition )) != -1 ) {
QString semi4 = expression4.cap( 1 );
notneed.append(QString("class=\"%1\"").arg(semi4));
notneed.append(QString("class='%1'").arg(semi4));
iPosition += expression4.matchedLength();
}
for (int i = 0; i < notneed.size(); ++i) {
const QString fluteremove = notneed.at(i);
prehtml = prehtml.replace(fluteremove,"", Qt::CaseInsensitive );
}
return prehtml;
}
To copy to clipboard, switch view to plain text mode
Bookmarks