Skip to content

Commit

Permalink
fix: when encoutering unwanted tags in paragaph translation by paragr…
Browse files Browse the repository at this point in the history
…aphs, it should continue instead of using break.
  • Loading branch information
plateaukao committed Feb 9, 2024
1 parent 2153917 commit a60522e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions app/src/main/java/info/plateaukao/einkbro/view/NinjaWebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1298,19 +1298,21 @@ highlightSelection();
child.getAttribute("data-tiara-action-name") === "헤드글씨크기_클릭" ||
child.innerText === "original link"
) {
break;
continue;
}
if(child.tagName === "SCRIPT") {
break;
continue;
}
if (child.closest('a, img, button')) {
continue;
}
if (
["p", "h1", "h2", "h3", "h4", "h5", "h6", "span"].includes(child.tagName.toLowerCase()) ||
["p", "h1", "h2", "h3", "h4", "h5", "h6", "span", "strong"].includes(child.tagName.toLowerCase()) ||
(child.children.length == 0 && child.innerText != "")
) {
if (child.innerText !== "") {
injectTranslateTag(child);
//console.log(child.textContent);
console.log(child.textContent + "\n\n");
result.push(child);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class TranslationViewModel : ViewModel(), KoinComponent {
// for locating element's position
node.id(index.toString())
// for later inserting translated text
node.after(Element("p").apply { addClass("einkbro_translated") })
node.after(Element("p"))
}
// add observer
val script: Element = parsedHtml.createElement("script")
Expand Down

0 comments on commit a60522e

Please sign in to comment.