mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix:website dictionary has informal html structure
This commit is contained in:
parent
0e0ffec16a
commit
1a2e648c40
|
@ -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));
|
||||
|
||||
|
|
Loading…
Reference in a new issue