mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
46c9376db2
|
@ -38,8 +38,7 @@ QRegularExpression Mdx::anchorIdRe2( R"(([\s"'](?:name|id)\s*=)\s*(?=[^"'])([^\s
|
|||
QRegularExpression Mdx::anchorLinkRe( R"(([\s"']href\s*=\s*["'])entry://#)",
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
const QRegularExpression Mdx::audioRe( R"(([\s"']href\s*=)\s*(["'])sound://([^">]+)\2)",
|
||||
QRegularExpression::CaseInsensitiveOption
|
||||
| QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
const QRegularExpression Mdx::stylesRe(
|
||||
R"(([\s"']href\s*=)\s*(["'])(?!\s*\b(?:(?:bres|https?|ftp)://|(?:data|javascript):))(?:file://)?[\x00-\x1f\x7f]*\.*/?([^">]+)\2)",
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
|
|
|
@ -923,7 +923,7 @@ void BglDictionary::replaceCharsetEntities( string & text )
|
|||
|
||||
QRegularExpression charsetExp(
|
||||
R"(<\s*charset\s+c\s*=\s*["']?t["']?\s*>((?:\s*[0-9a-fA-F]+\s*;\s*)*)<\s*/\s*charset\s*>)",
|
||||
QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
|
||||
QRegularExpression oneValueExp( "\\s*([0-9a-fA-F]+)\\s*;" );
|
||||
QString result;
|
||||
|
|
|
@ -378,6 +378,7 @@ void Class::isolateCSS( QString & css, QString const & wrapperSelector )
|
|||
if ( css.isEmpty() )
|
||||
return;
|
||||
|
||||
//comment syntax like:/* */
|
||||
QRegularExpression reg1( R"(\/\*(?:.(?!\*\/))*.?\*\/)", QRegularExpression::DotMatchesEverythingOption );
|
||||
QRegularExpression reg2( R"([ \*\>\+,;:\[\{\]])" );
|
||||
QRegularExpression reg3( "[,;\\{]" );
|
||||
|
@ -393,6 +394,9 @@ void Class::isolateCSS( QString & css, QString const & wrapperSelector )
|
|||
// Strip comments
|
||||
css.replace( reg1, QString() );
|
||||
|
||||
//replace the pseudo root selector with the prefix,like ":root {" to "html{"
|
||||
css.replace( QRegularExpression( R"(:root\s*{)" ), "html{" );
|
||||
|
||||
for ( ;; ) {
|
||||
if ( currentPos >= css.length() )
|
||||
break;
|
||||
|
|
|
@ -688,10 +688,10 @@ void GlsDictionary::loadArticle( uint32_t address, string & headword, string & a
|
|||
|
||||
QString & GlsDictionary::filterResource( QString & article )
|
||||
{
|
||||
QRegularExpression imgRe( R"((<\s*img\s+[^>]*src\s*=\s*["']+)(?!(?:data|https?|ftp|qrcx):))",
|
||||
QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']+)(?!(?:data|https?|ftp):))",
|
||||
QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression imgRe( R"((<\s*(?:img|script)\s+[^>]*src\s*=\s*["']?)(?!(?:data|https?|ftp|qrcx):))",
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']?)(?!(?:data|https?|ftp):))",
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
|
||||
article.replace( imgRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" )
|
||||
.replace( linkRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" );
|
||||
|
@ -742,8 +742,8 @@ QString & GlsDictionary::filterResource( QString & article )
|
|||
// Handle "audio" tags
|
||||
|
||||
QRegularExpression audioRe( R"(<\s*audio\s+src\s*=\s*(["']+)([^"']+)(["'])\s*>(.*)</audio>)",
|
||||
QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption
|
||||
| QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression::CaseInsensitiveOption
|
||||
| QRegularExpression::DotMatchesEverythingOption );
|
||||
|
||||
|
||||
pos = 0;
|
||||
|
|
|
@ -454,11 +454,9 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
|
|||
QString articleText = QString( "<div class=\"sdct_h\">" ) + QString::fromUtf8( resource, size ) + "</div>";
|
||||
|
||||
QRegularExpression imgRe( R"((<\s*(?:img|script)\s+[^>]*src\s*=\s*["']?)(?!(?:data|https?|ftp):))",
|
||||
QRegularExpression::CaseInsensitiveOption
|
||||
| QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']?)(?!(?:data|https?|ftp):))",
|
||||
QRegularExpression::CaseInsensitiveOption
|
||||
| QRegularExpression::InvertedGreedinessOption );
|
||||
QRegularExpression::CaseInsensitiveOption );
|
||||
|
||||
articleText.replace( imgRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" )
|
||||
.replace( linkRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" );
|
||||
|
@ -517,8 +515,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
|
|||
|
||||
QRegularExpression audioRe( R"(<\s*audio\s*src\s*=\s*(["']+)([^"']+)(["'])\s*>(.*)</audio>)",
|
||||
QRegularExpression::CaseInsensitiveOption
|
||||
| QRegularExpression::DotMatchesEverythingOption
|
||||
| QRegularExpression::InvertedGreedinessOption );
|
||||
| QRegularExpression::DotMatchesEverythingOption );
|
||||
|
||||
|
||||
pos = 0;
|
||||
|
|
Loading…
Reference in a new issue