mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt: when the marked word is CJK / Han, mark it partially (#1852)
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
* opt: when the marked word is Chinese,mark it partially * [autofix.ci] apply automated fixes * Update src/ui/articleview.cc Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: shenleban tongying <shenlebantongying@gmail.com>
This commit is contained in:
parent
3e16a0cccf
commit
245cb10880
|
@ -2058,11 +2058,19 @@ void ArticleView::highlightFTSResults()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString accuracy = "exactly";
|
||||||
|
|
||||||
|
if ( std::any_of( regString.begin(), regString.end(), []( QChar & a ) {
|
||||||
|
return a.script() == QChar::Script_Han;
|
||||||
|
} ) ) {
|
||||||
|
accuracy = "partially";
|
||||||
|
}
|
||||||
|
|
||||||
QString script = QString(
|
QString script = QString(
|
||||||
"var context = document.querySelector(\"body\");\n"
|
"var context = document.querySelector(\"body\");\n"
|
||||||
"var instance = new Mark(context);\n instance.unmark();\n"
|
"var instance = new Mark(context);\n instance.unmark();\n"
|
||||||
"instance.mark(\"%1\",{\"accuracy\": \"exactly\"});" )
|
"instance.mark(\"%1\",{\"accuracy\": \"%2\"});" )
|
||||||
.arg( regString );
|
.arg( regString, accuracy );
|
||||||
|
|
||||||
webview->page()->runJavaScript( script );
|
webview->page()->runJavaScript( script );
|
||||||
auto parts = regString.split( " ", Qt::SkipEmptyParts );
|
auto parts = regString.split( " ", Qt::SkipEmptyParts );
|
||||||
|
|
Loading…
Reference in a new issue