Browse Source

disable furigana cleaning

main
parent
commit
ae3e2840e1
1 changed files with 19 additions and 9 deletions
  1. +19
    -9
      src/wanikani.ts

+ 19
- 9
src/wanikani.ts View File

@ -365,9 +365,9 @@ export class WaniKani {
for (const n of notes) {
const { value: ja } = n.fields[fields.ja] || {};
if (ja) {
const audio = audioMap.get(
ja.replace(/\[.+?\]/g, '').replace(/ /g, ''),
);
// const cleanJa = ja.replace(/\[.+?\]/g, '').replace(/ /g, '')
const cleanJa = ja;
const audio = audioMap.get(cleanJa);
if (audio) {
notesToUpdate.push({
id: n.noteId,
@ -467,7 +467,8 @@ export class WaniKani {
for (const n of notes) {
const { value: ja } = n.fields[fields.vocabJa] || {};
if (ja) {
const cleanJa = ja.replace(/\[.+?\]/g, '').replace(/ /g, '');
// const cleanJa = ja.replace(/\[.+?\]/g, '').replace(/ /g, '');
const cleanJa = ja;
const sent = sentenceMap.get(cleanJa);
if (sent) {
const fieldUpdate = {
@ -479,10 +480,19 @@ export class WaniKani {
fields.sentenceCloze &&
!n.fields[fields.sentenceCloze]?.value
) {
fieldUpdate[fields.sentenceCloze] = sent.sentences
const clozeChar = '__';
let newSent = sent.sentences
.map(({ ja, en }) => `${ja}<br/>${en}`)
.join('<br/>')
.replace(cleanJa, '__');
.replace(cleanJa, clozeChar);
cleanJa.split(/[\p{sc=Hiragana}]+/gu).map((c) => {
if (c) {
newSent = newSent.replace(c, clozeChar);
}
});
fieldUpdate[fields.sentenceCloze] = newSent;
}
notesToUpdate.push({
@ -554,9 +564,9 @@ export class WaniKani {
for (const n of notes) {
const { value: ja } = n.fields[fields.ja] || {};
if (ja) {
const vocab = vocabMap.get(
ja.replace(/\[.+?\]/g, '').replace(/ /g, ''),
);
// const cleanJa = ja.replace(/\[.+?\]/g, '').replace(/ /g, '')
const cleanJa = ja;
const vocab = vocabMap.get(cleanJa);
if (vocab) {
notesToUpdate.push({
id: n.noteId,

Loading…
Cancel
Save