Heighlight text improvements

pull/210/head
M66B 3 years ago
parent 2ede17a7d0
commit 1c32eee3bc

@ -2960,11 +2960,12 @@ public class HtmlHelper {
return ssb;
}
static Document highlightSearched(Context context, Document document, String query) {
static void highlightSearched(Context context, Document document, String query) {
try {
int color = Helper.resolveColor(context, R.attr.colorHighlight);
query = Normalizer.normalize(query, Normalizer.Form.NFKD)
.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
query = Fts4DbHelper.preprocessText(query);
// TODO breakText
// TODO: fix highlighting pre processed text
List<String> word = new ArrayList<>();
@ -2972,9 +2973,9 @@ public class HtmlHelper {
for (String w : query.trim().split("\\s+"))
if (w.length() > 1 && (w.startsWith("+") || w.startsWith("-"))) {
if (w.startsWith("+"))
plus.add(w.substring(1));
plus.add(Pattern.quote(w.substring(1)));
} else
word.add(w);
word.add(Pattern.quote(w));
int flags = Pattern.DOTALL | Pattern.CASE_INSENSITIVE;
List<Pattern> pat = new ArrayList<>();
@ -2989,8 +2990,7 @@ public class HtmlHelper {
if (node instanceof TextNode)
try {
TextNode tnode = (TextNode) node;
String text = Normalizer.normalize(tnode.getWholeText(), Normalizer.Form.NFKD)
.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
String text = Fts4DbHelper.preprocessText(tnode.getWholeText());
Matcher result = p.matcher(text);
@ -3030,8 +3030,9 @@ public class HtmlHelper {
public void tail(Node node, int depth) {
}
}, document);
return document;
} catch (Throwable ex) {
Log.e(ex);
}
}
static Document markText(Document document) {

Loading…
Cancel
Save