diff --git a/background-script.js b/background-script.js index 76d2ea7..3e986c7 100644 --- a/background-script.js +++ b/background-script.js @@ -560,7 +560,7 @@ rules.push({type: "onlyfinalrule", dec_end:"る", con_end:"ん", dec_tag:"vk", c //rules.push({type: "stdrule", dec_end:"", con_end:"たい", dec_tag:"stem-ren", con_tag:"adj-i", detail:"want"}); -// FIXME implement un-deconjugation to show the actual reading of the deconjugated word - this is what furigana rules are for +// FIXME implement un-deconjugation to show the actual reading of the deconjugated word e.g. of 来る or 得る - this is what furigana rules are for // return deconjugated form if stdrule applies to form, return otherwise function stdrule_deconjugate_inner(my_form, my_rule) diff --git a/mining.js b/mining.js index e26e7f6..8fe6d81 100644 --- a/mining.js +++ b/mining.js @@ -24,26 +24,28 @@ async function init_page() let text = ""; for(let card of data) { - text += card.front.replace("\t", "\\t"); + text += card.front.replace(/\t/g, "\\t"); text += "\t"; - text += card.readings.replace("\t", "\\t"); + text += card.readings.replace(/\t/g, "\\t"); text += "\t"; - text += card.definitions.replace("\t", "\\t"); + text += card.definitions.trim().replace(/\t/g, "\\t"); text += "\t"; try - { text += card.lookup.replace("\t", "\\t"); + { text += card.lookup.replace(/\t/g, "\\t"); text += "\t"; } catch(e) {} try - { text += card.sentence.replace("\t", "\\t"); + { text += card.sentence.replace(/\t/g, "\\t"); text += "\t"; } catch(e) {} try - { text += card.index.replace("\t", "\\t"); + { text += card.index.replace(/\t/g, "\\t"); text += "\t"; } catch(e) {} - text += card.seq.replace("\t", "\\t"); - text.replace("\n", "\\n").replace("\r", ""); + text += card.seq.replace(/\t/g, "\\t"); + console.log(text); + text = text.replace(/\n/g, "\\n").replace(/\r/g, ""); + console.log(text); text += "\n"; } let element = document.body.querySelector("#field"); diff --git a/texthook.js b/texthook.js index 1df8195..8145ead 100644 --- a/texthook.js +++ b/texthook.js @@ -1004,6 +1004,7 @@ function lookup_cancel_force() } let japanesePunctuation = "、。「」{}()【】『』〈〉《》:・/…︙‥︰+=-÷?!.~―"; +let japaneseSeparators = "。?!"; function lookup_left() { @@ -1162,11 +1163,11 @@ function grab_text(textNode, offset, elemental) let leftwards = 0; let rightwards = 0; - while(moreText[index + leftwards] != "。" && moreText[index + leftwards] != "\n" && index + leftwards >= 0) + while(!japaneseSeparators.includes(moreText[index + leftwards]) && moreText[index + leftwards] != "\n" && index + leftwards >= 0) leftwards--; leftwards++; - while(moreText[index + rightwards] != "。" && moreText[index + rightwards] != "\n" && index + rightwards < moreText.length) + while(!japaneseSeparators.includes(moreText[index + rightwards]) && moreText[index + rightwards] != "\n" && index + rightwards < moreText.length) rightwards++; moreText = moreText.substring(index+leftwards, index+rightwards); @@ -1381,7 +1382,7 @@ function mine(highlight) let readings_elements = word.getElementsByClassName("nazeka_readings"); if(readings_elements.length) readings = readings_elements[0].textContent; - let definitions = word.getElementsByClassName("nazeka_definitions")[0].textContent; + let definitions = word.getElementsByClassName("nazeka_definitions")[0].innerText; // innerText retains newlines, which we actually want let lookup = word.parentElement.querySelector(".nazeka_lookup"); let sentence = word.parentElement.querySelector(".nazeka_lookup_sentence"); let index = word.parentElement.querySelector(".nazeka_lookup_index");