fix:website dictionary has informal html structure

This commit is contained in:
Xiao YiFang 2022-08-10 19:49:31 +08:00
parent 0e0ffec16a
commit 1a2e648c40

View file

@ -55,13 +55,19 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
articleString.remove( baseTag ) ;
QRegularExpression headTag( "<head\\b.*?>",
QRegularExpression::CaseInsensitiveOption
| QRegularExpression::DotMatchesEverythingOption );
QRegularExpression::CaseInsensitiveOption
| QRegularExpression::DotMatchesEverythingOption );
auto match = headTag.match( articleString, 0 );
if( match.hasMatch() )
{
articleString.insert( match.capturedEnd(), baseTagHtml );
}
else
{
// the html contain no head element
// just insert at the beginning of the html ,and leave it at the mercy of browser(chrome webengine)
articleString.insert( 0, baseTagHtml );
}
buffer->setData(codec->fromUnicode(articleString));