henkan 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/index.cjs.js +55 -79
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.mjs +39 -51
- package/dist/index.mjs.map +1 -1
- package/dist/types/types.d.ts +4 -4
- package/dist/types/types.d.ts.map +1 -1
- package/docs/api/interfaces/JaWiktionaryEntry.md +4 -4
- package/package.json +5 -3
- package/src/types.ts +4 -4
- package/tsconfig.json +60 -0
- package/tsconfig.types.json +9 -0
package/LICENSE.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1357,10 +1357,10 @@ function getValidForms(readings, kanjiForms, wordIsCommon) {
|
|
|
1357
1357
|
return false;
|
|
1358
1358
|
}
|
|
1359
1359
|
);
|
|
1360
|
-
const existValidKf = kanjiForms
|
|
1360
|
+
const existValidKf = kanjiForms?.some(
|
|
1361
1361
|
(kf, index) => index !== 0 && (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note)) && (wordIsCommon === void 0 || kf.commonness !== void 0) || kanjiFormRestrictions.has(kf.form))
|
|
1362
1362
|
);
|
|
1363
|
-
const validKanjiForms = kanjiForms
|
|
1363
|
+
const validKanjiForms = kanjiForms?.filter(
|
|
1364
1364
|
(kanjiForm, index) => {
|
|
1365
1365
|
if (index === 0) return true;
|
|
1366
1366
|
if (existValidKf === true)
|
|
@@ -1563,7 +1563,6 @@ function convertKanjiDic(xmlString) {
|
|
|
1563
1563
|
return dict;
|
|
1564
1564
|
}
|
|
1565
1565
|
function convertTanakaCorpus(tanakaString) {
|
|
1566
|
-
var _a, _b;
|
|
1567
1566
|
const tanakaArray = [];
|
|
1568
1567
|
const tanakaParsed = tanakaString.split("\n");
|
|
1569
1568
|
for (let i = 0; i <= tanakaParsed.length; i += 2) {
|
|
@@ -1572,7 +1571,7 @@ function convertTanakaCorpus(tanakaString) {
|
|
|
1572
1571
|
if (a !== void 0 && b !== void 0 && a.startsWith("A: ") && b.startsWith("B: ")) {
|
|
1573
1572
|
a = a.replace("A: ", "");
|
|
1574
1573
|
b = b.replace("B: ", "");
|
|
1575
|
-
const idMatch =
|
|
1574
|
+
const idMatch = regexps.tanakaID.exec(a)?.groups["id"]?.trim();
|
|
1576
1575
|
const idParts = String(idMatch).split("_");
|
|
1577
1576
|
const id = `${Number(idParts[0])}_${Number(idParts[1])}`;
|
|
1578
1577
|
const aParts = a.replace(regexps.tanakaID, "").split(" ");
|
|
@@ -1580,16 +1579,16 @@ function convertTanakaCorpus(tanakaString) {
|
|
|
1580
1579
|
const bParts = [];
|
|
1581
1580
|
for (const part of bRawParts) {
|
|
1582
1581
|
const partMatches = regexps.tanakaPart.exec(part);
|
|
1583
|
-
const baseForm = partMatches
|
|
1582
|
+
const baseForm = partMatches?.groups["base"];
|
|
1584
1583
|
const examplePart = { baseForm };
|
|
1585
|
-
const reading = partMatches
|
|
1586
|
-
const glossNumber = partMatches
|
|
1587
|
-
const inflectedForm = partMatches
|
|
1584
|
+
const reading = partMatches?.groups["reading"];
|
|
1585
|
+
const glossNumber = partMatches?.groups["glossnum"];
|
|
1586
|
+
const inflectedForm = partMatches?.groups["inflection"];
|
|
1588
1587
|
if (reading !== void 0)
|
|
1589
1588
|
if (regexps.tanakaReferenceID.test(reading)) {
|
|
1590
1589
|
const referenceID = regexps.tanakaReferenceID.exec(reading);
|
|
1591
1590
|
examplePart.referenceID = `${Number(
|
|
1592
|
-
referenceID
|
|
1591
|
+
referenceID?.groups["entryid"]
|
|
1593
1592
|
)}`;
|
|
1594
1593
|
} else examplePart.reading = reading;
|
|
1595
1594
|
if (glossNumber !== void 0)
|
|
@@ -1679,7 +1678,7 @@ function convertKradFile(kradBuffer, kanjiDic, katakanaList) {
|
|
|
1679
1678
|
const foundRadical = kanjiDic.find(
|
|
1680
1679
|
(dictKanji) => dictKanji.kanji === radical
|
|
1681
1680
|
);
|
|
1682
|
-
let radicalObj = foundRadical
|
|
1681
|
+
let radicalObj = foundRadical ?? { kanji: radical };
|
|
1683
1682
|
if (foundRadical === void 0) {
|
|
1684
1683
|
const katakanaChar = katakanaList.find(
|
|
1685
1684
|
(kana) => kana.kana === radical
|
|
@@ -1707,7 +1706,6 @@ function convertKradFile(kradBuffer, kanjiDic, katakanaList) {
|
|
|
1707
1706
|
return kanjiWithRadicals;
|
|
1708
1707
|
}
|
|
1709
1708
|
function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs, svgList) {
|
|
1710
|
-
var _a;
|
|
1711
1709
|
const kanjiEntryMap = /* @__PURE__ */ new Map();
|
|
1712
1710
|
const wordIDEntryMap = /* @__PURE__ */ new Map();
|
|
1713
1711
|
const kanjiWordsMap = /* @__PURE__ */ new Map();
|
|
@@ -1808,7 +1806,7 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
|
|
|
1808
1806
|
const seenEx = /* @__PURE__ */ new Set();
|
|
1809
1807
|
const validExamples = [];
|
|
1810
1808
|
for (const p of wordPartsMap.get(word.id)) {
|
|
1811
|
-
const examplesForPart =
|
|
1809
|
+
const examplesForPart = partExamplesMap.get(p)?.filter((ex) => !seenEx.has(ex.id));
|
|
1812
1810
|
if (examplesForPart === void 0) continue;
|
|
1813
1811
|
for (const ex of examplesForPart) {
|
|
1814
1812
|
seenEx.add(ex.id);
|
|
@@ -1845,11 +1843,10 @@ function mapEntry(entry) {
|
|
|
1845
1843
|
};
|
|
1846
1844
|
}
|
|
1847
1845
|
function convertJawiktionarySync(buffer) {
|
|
1848
|
-
var _a;
|
|
1849
1846
|
const lines = buffer.toString("utf-8").split("\n");
|
|
1850
1847
|
const entries = [];
|
|
1851
1848
|
for (let i = 0; i < lines.length; i++) {
|
|
1852
|
-
const line =
|
|
1849
|
+
const line = lines[i]?.trim();
|
|
1853
1850
|
if (line === void 0 || line.length === 0) continue;
|
|
1854
1851
|
const obj = JSON.parse(line);
|
|
1855
1852
|
if (typeof obj === "object" && (obj.lang === "\u65E5\u672C\u8A9E" || obj.lang === "\u53E4\u5178\u65E5\u672C\u8A9E"))
|
|
@@ -1885,7 +1882,6 @@ function parseEntry(entry, definitions, definitionMap) {
|
|
|
1885
1882
|
}
|
|
1886
1883
|
}
|
|
1887
1884
|
function getWordDefinitions(wiktionaryEntries, jmDict) {
|
|
1888
|
-
var _a, _b, _c, _d, _e;
|
|
1889
1885
|
const entries = /* @__PURE__ */ new Map();
|
|
1890
1886
|
for (const entry of wiktionaryEntries) {
|
|
1891
1887
|
const ent = entries.get(entry.word);
|
|
@@ -2023,7 +2019,7 @@ function getWordDefinitions(wiktionaryEntries, jmDict) {
|
|
|
2023
2019
|
for (const m of word.meanings)
|
|
2024
2020
|
for (const note of m.partOfSpeech) {
|
|
2025
2021
|
const noteEntry = noteMap.get(note);
|
|
2026
|
-
if (
|
|
2022
|
+
if (noteEntry?.length === 3) {
|
|
2027
2023
|
const notePos = noteEntry[2];
|
|
2028
2024
|
if (Array.isArray(notePos))
|
|
2029
2025
|
for (const pos of notePos) {
|
|
@@ -2042,8 +2038,8 @@ function getWordDefinitions(wiktionaryEntries, jmDict) {
|
|
|
2042
2038
|
const posEntries = posMap.get(pos);
|
|
2043
2039
|
if (rkf.kanjiForms !== void 0)
|
|
2044
2040
|
for (const kf of rkf.kanjiForms) {
|
|
2045
|
-
const te =
|
|
2046
|
-
const fe =
|
|
2041
|
+
const te = posEntries.title?.get(kf);
|
|
2042
|
+
const fe = posEntries.form?.get(kf);
|
|
2047
2043
|
if (te !== void 0)
|
|
2048
2044
|
entriesWithTitles.push(
|
|
2049
2045
|
...te.filter(
|
|
@@ -2060,9 +2056,9 @@ function getWordDefinitions(wiktionaryEntries, jmDict) {
|
|
|
2060
2056
|
);
|
|
2061
2057
|
}
|
|
2062
2058
|
for (const r of rkf.readings) {
|
|
2063
|
-
const te =
|
|
2064
|
-
const fe =
|
|
2065
|
-
const fte =
|
|
2059
|
+
const te = posEntries.title?.get(r);
|
|
2060
|
+
const fe = posEntries.form?.get(r);
|
|
2061
|
+
const fte = posEntries.formTitle?.get(r);
|
|
2066
2062
|
if (te !== void 0)
|
|
2067
2063
|
entriesWithTitles.push(
|
|
2068
2064
|
...te.filter(
|
|
@@ -2276,7 +2272,6 @@ var wordAddNoteArray = (arr, cb) => {
|
|
|
2276
2272
|
for (const v of arr) cb(v);
|
|
2277
2273
|
};
|
|
2278
2274
|
function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath) {
|
|
2279
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2280
2275
|
let dictKanji = void 0;
|
|
2281
2276
|
if (typeof searchedKanji === "string" && dict !== void 0)
|
|
2282
2277
|
dictKanji = dict instanceof Map ? dict.get(searchedKanji) : dict.find((entry) => entry.kanji === searchedKanji);
|
|
@@ -2285,9 +2280,9 @@ function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath)
|
|
|
2285
2280
|
const kanji = {
|
|
2286
2281
|
kanji: dictKanji.kanji,
|
|
2287
2282
|
strokes: dictKanji.misc.strokeNumber,
|
|
2288
|
-
...
|
|
2289
|
-
...
|
|
2290
|
-
...
|
|
2283
|
+
...dictKanji.misc?.grade !== void 0 ? { grade: dictKanji.misc.grade } : {},
|
|
2284
|
+
...dictKanji.misc?.frequency !== void 0 ? { frequency: dictKanji.misc.frequency } : {},
|
|
2285
|
+
...dictKanji.misc?.jlpt !== void 0 ? { jlpt: dictKanji.misc.jlpt } : {},
|
|
2291
2286
|
noteID: `kanji_${dictKanji.kanji}`,
|
|
2292
2287
|
...noteTypeName !== void 0 ? { noteTypeName } : {},
|
|
2293
2288
|
...deckPath !== void 0 ? { deckPath } : {},
|
|
@@ -2323,7 +2318,7 @@ function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath)
|
|
|
2323
2318
|
}
|
|
2324
2319
|
if (jmDict !== void 0) {
|
|
2325
2320
|
let kanjiWords = jmDict instanceof Map ? jmDict.get(kanji.kanji) : jmDict;
|
|
2326
|
-
const firstKfWords = kanjiWords
|
|
2321
|
+
const firstKfWords = kanjiWords?.filter(
|
|
2327
2322
|
(word) => word.kanjiForms !== void 0 && word.kanjiForms[0].form.includes(kanji.kanji)
|
|
2328
2323
|
);
|
|
2329
2324
|
if (firstKfWords !== void 0 && firstKfWords.length > 0)
|
|
@@ -2331,17 +2326,17 @@ function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath)
|
|
|
2331
2326
|
if (kanjiWords !== void 0) {
|
|
2332
2327
|
const validWords = [];
|
|
2333
2328
|
for (const word of kanjiWords) {
|
|
2334
|
-
const kanjiForm = (
|
|
2329
|
+
const kanjiForm = (firstKfWords !== void 0 && firstKfWords.length > 0 ? word.kanjiForms[0] : word.kanjiForms.find(
|
|
2335
2330
|
(kf) => kf.form.includes(kanji.kanji)
|
|
2336
|
-
))
|
|
2331
|
+
))?.form;
|
|
2337
2332
|
if (kanjiForm !== void 0) {
|
|
2338
|
-
const reading = (
|
|
2333
|
+
const reading = (firstKfWords !== void 0 && firstKfWords.length > 0 ? word.readings[0] : word.readings.find(
|
|
2339
2334
|
(r) => r.kanjiFormRestrictions !== void 0 && r.kanjiFormRestrictions.includes(kanjiForm)
|
|
2340
|
-
))
|
|
2335
|
+
))?.reading;
|
|
2341
2336
|
if (reading === void 0) continue;
|
|
2342
|
-
const translation = (
|
|
2337
|
+
const translation = (firstKfWords !== void 0 && firstKfWords.length > 0 ? word.meanings[0] : word.meanings.find(
|
|
2343
2338
|
(m) => m.kanjiFormRestrictions !== void 0 && m.kanjiFormRestrictions.includes(kanjiForm)
|
|
2344
|
-
))
|
|
2339
|
+
))?.translations.map(
|
|
2345
2340
|
(t) => typeof t === "string" ? t : t.translation
|
|
2346
2341
|
)[0];
|
|
2347
2342
|
if (translation === void 0) continue;
|
|
@@ -2378,10 +2373,10 @@ function getKanji(searchedKanji, dict, jmDict, svgList, noteTypeName, deckPath)
|
|
|
2378
2373
|
...kanji.frequency !== void 0 ? [`kanji::frequency::${kanji.frequency}`] : [],
|
|
2379
2374
|
...kanji.grade !== void 0 ? [`kanji::grade::${kanji.grade}`] : [],
|
|
2380
2375
|
...kanji.jlpt !== void 0 ? [`kanji::pre-2010_jlpt::${kanji.jlpt.toLowerCase()}`] : [],
|
|
2381
|
-
`kanji::onyomi::${
|
|
2382
|
-
`kanji::kunyomi::${
|
|
2383
|
-
`kanji::nanori::${
|
|
2384
|
-
`kanji::words::${
|
|
2376
|
+
`kanji::onyomi::${kanji.onyomi?.length ?? 0}`,
|
|
2377
|
+
`kanji::kunyomi::${kanji.kunyomi?.length ?? 0}`,
|
|
2378
|
+
`kanji::nanori::${kanji.nanori?.length ?? 0}`,
|
|
2379
|
+
`kanji::words::${kanji.words?.length ?? 0}`,
|
|
2385
2380
|
...kanji.svg !== void 0 ? ["kanji::has_svg"] : []
|
|
2386
2381
|
);
|
|
2387
2382
|
return kanji;
|
|
@@ -2426,7 +2421,6 @@ function getKanjiExtended(info, kanji, dict, useWords, jmDict, svgList, noteType
|
|
|
2426
2421
|
} else return void 0;
|
|
2427
2422
|
}
|
|
2428
2423
|
function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeName, deckPath) {
|
|
2429
|
-
var _a, _b;
|
|
2430
2424
|
let dictWord = void 0;
|
|
2431
2425
|
if (typeof searchedWord === "string" && dict !== void 0) {
|
|
2432
2426
|
if (Array.isArray(dict))
|
|
@@ -2560,7 +2554,7 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2560
2554
|
seenChars.add(char);
|
|
2561
2555
|
const kanjiEntry = kanjiDic instanceof Map ? kanjiDic.get(char) : void 0;
|
|
2562
2556
|
const kanjiObj = getKanji(
|
|
2563
|
-
kanjiEntry
|
|
2557
|
+
kanjiEntry ?? char,
|
|
2564
2558
|
!(kanjiDic instanceof Map) ? kanjiDic : void 0
|
|
2565
2559
|
);
|
|
2566
2560
|
if (kanjiObj !== void 0)
|
|
@@ -2572,7 +2566,7 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2572
2566
|
if (kanji.length > 0) word.kanji = kanji;
|
|
2573
2567
|
}
|
|
2574
2568
|
if (dictWord.hasPhrases === true && examples !== void 0) {
|
|
2575
|
-
const exampleList = examples instanceof Map ?
|
|
2569
|
+
const exampleList = examples instanceof Map ? examples.get(dictWord.id) ?? [] : examples;
|
|
2576
2570
|
const rkf = getValidForms(
|
|
2577
2571
|
dictWord.readings,
|
|
2578
2572
|
dictWord.kanjiForms,
|
|
@@ -2657,31 +2651,25 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2657
2651
|
wordExamples = glossSpecificExamples;
|
|
2658
2652
|
}
|
|
2659
2653
|
if (wordExamples.length > 0) {
|
|
2660
|
-
word.phrases = (glossSpecificExamples.length === 0 ? wordExamples.slice(0, 5) : wordExamples).map((ex) => {
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
...ex.ex.glossNumber !== void 0 ? { glossNumber: ex.ex.glossNumber } : {}
|
|
2667
|
-
};
|
|
2668
|
-
});
|
|
2654
|
+
word.phrases = (glossSpecificExamples.length === 0 ? wordExamples.slice(0, 5) : wordExamples).map((ex) => ({
|
|
2655
|
+
phrase: ex.ex.furigana ?? ex.ex.phrase,
|
|
2656
|
+
translation: ex.ex.translation,
|
|
2657
|
+
originalPhrase: ex.ex.phrase,
|
|
2658
|
+
...ex.ex.glossNumber !== void 0 ? { glossNumber: ex.ex.glossNumber } : {}
|
|
2659
|
+
}));
|
|
2669
2660
|
word.tags.push("word::has_phrases");
|
|
2670
2661
|
if (glossSpecificExamples.length > 0)
|
|
2671
2662
|
word.tags.push("word::has_meaning-specific_phrases");
|
|
2672
2663
|
}
|
|
2673
2664
|
}
|
|
2674
2665
|
if (definitions !== void 0) {
|
|
2675
|
-
const defs = definitions instanceof Map ? definitions.get(word.id) :
|
|
2666
|
+
const defs = definitions instanceof Map ? definitions.get(word.id) : definitions.find(
|
|
2676
2667
|
(wdp) => wdp.wordID === word.id
|
|
2677
|
-
)
|
|
2668
|
+
)?.definitions;
|
|
2678
2669
|
if (defs !== void 0)
|
|
2679
2670
|
word.definitions = [
|
|
2680
2671
|
...defs.toSorted(
|
|
2681
|
-
(a, b) =>
|
|
2682
|
-
var _a2, _b2;
|
|
2683
|
-
return ((_a2 = a.mayNotBeAccurate) != null ? _a2 : 0) - ((_b2 = b.mayNotBeAccurate) != null ? _b2 : 0);
|
|
2684
|
-
}
|
|
2672
|
+
(a, b) => (a.mayNotBeAccurate ?? 0) - (b.mayNotBeAccurate ?? 0)
|
|
2685
2673
|
)
|
|
2686
2674
|
];
|
|
2687
2675
|
}
|
|
@@ -2689,29 +2677,23 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
|
|
|
2689
2677
|
} else return void 0;
|
|
2690
2678
|
}
|
|
2691
2679
|
function isWord(entry) {
|
|
2692
|
-
|
|
2693
|
-
return isObjectArray((_a = Object.getOwnPropertyDescriptor(entry, "readings")) == null ? void 0 : _a.value) && isObjectArray((_b = Object.getOwnPropertyDescriptor(entry, "translations")) == null ? void 0 : _b.value);
|
|
2680
|
+
return isObjectArray(Object.getOwnPropertyDescriptor(entry, "readings")?.value) && isObjectArray(Object.getOwnPropertyDescriptor(entry, "translations")?.value);
|
|
2694
2681
|
}
|
|
2695
2682
|
function isRadical(entry) {
|
|
2696
|
-
|
|
2697
|
-
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "radical")) == null ? void 0 : _a.value) === "string";
|
|
2683
|
+
return typeof Object.getOwnPropertyDescriptor(entry, "radical")?.value === "string";
|
|
2698
2684
|
}
|
|
2699
2685
|
function isKanji(entry) {
|
|
2700
|
-
|
|
2701
|
-
return !Object.hasOwn(entry, "translations") && !Object.hasOwn(entry, "readings") && !Object.hasOwn(entry, "radical") && typeof ((_a = Object.getOwnPropertyDescriptor(entry, "kanji")) == null ? void 0 : _a.value) === "string";
|
|
2686
|
+
return !Object.hasOwn(entry, "translations") && !Object.hasOwn(entry, "readings") && !Object.hasOwn(entry, "radical") && typeof Object.getOwnPropertyDescriptor(entry, "kanji")?.value === "string";
|
|
2702
2687
|
}
|
|
2703
2688
|
function isKana(entry) {
|
|
2704
|
-
|
|
2705
|
-
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "kana")) == null ? void 0 : _a.value) === "string";
|
|
2689
|
+
return typeof Object.getOwnPropertyDescriptor(entry, "kana")?.value === "string";
|
|
2706
2690
|
}
|
|
2707
2691
|
function isGrammar(entry) {
|
|
2708
|
-
|
|
2709
|
-
return typeof ((_a = Object.getOwnPropertyDescriptor(entry, "point")) == null ? void 0 : _a.value) === "string";
|
|
2692
|
+
return typeof Object.getOwnPropertyDescriptor(entry, "point")?.value === "string";
|
|
2710
2693
|
}
|
|
2711
2694
|
var createNotes = (notes, phrase) => `${phrase === true ? "<details><summary>Show translation</summary>" : ""}<ul class="note-list">${notes.map((note) => `<li class="note">${note}</li>`).join("")}</ul>${phrase === true ? "</details>" : ""}`;
|
|
2712
2695
|
var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific === true ? " gloss-specific" : ""}">${entry}${notes !== void 0 && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
|
|
2713
2696
|
function generateAnkiNote(entry) {
|
|
2714
|
-
var _a, _b;
|
|
2715
2697
|
const fields = [];
|
|
2716
2698
|
if (isWord(entry)) {
|
|
2717
2699
|
const firstReading = createEntry(
|
|
@@ -2763,7 +2745,7 @@ function generateAnkiNote(entry) {
|
|
|
2763
2745
|
);
|
|
2764
2746
|
}).filter((translation) => translation !== "null").join("")}</details>` : "";
|
|
2765
2747
|
const translationsField = `${firstThreeTranslations}${otherTranslations}`;
|
|
2766
|
-
const firstFivePhrases =
|
|
2748
|
+
const firstFivePhrases = entry.phrases?.slice(0, 5).map(
|
|
2767
2749
|
(phraseEntry, index) => createEntry(
|
|
2768
2750
|
`<span class="word word-phrase"><span class="word word-phrase-original">${phraseEntry.originalPhrase}</span><span class="word word-phrase-furigana">${phraseEntry.phrase}</span></span>`,
|
|
2769
2751
|
[phraseEntry.translation],
|
|
@@ -2785,21 +2767,15 @@ function generateAnkiNote(entry) {
|
|
|
2785
2767
|
);
|
|
2786
2768
|
}).filter((phrase) => phrase !== "null").join("")}</details>` : "";
|
|
2787
2769
|
const phrasesField = firstFivePhrases !== void 0 ? `${firstFivePhrases}${otherPhrases}` : '<span class="word word-phrase">(no phrases) (Search on dictionaries!)</span>';
|
|
2788
|
-
const firstThreeDefinitions =
|
|
2789
|
-
(definitionEntry) =>
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a2 = definitionEntry.furigana) != null ? _a2 : definitionEntry.definition}</span></span>`
|
|
2793
|
-
);
|
|
2794
|
-
}
|
|
2770
|
+
const firstThreeDefinitions = entry.definitions?.slice(0, 3).map(
|
|
2771
|
+
(definitionEntry) => createEntry(
|
|
2772
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${definitionEntry.furigana ?? definitionEntry.definition}</span></span>`
|
|
2773
|
+
)
|
|
2795
2774
|
).join("");
|
|
2796
2775
|
const otherDefinitions = entry.definitions !== void 0 && entry.definitions.length > 3 ? `<details><summary>Show other definitions</summary>${entry.definitions.map(
|
|
2797
|
-
(definitionEntry, index) =>
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${(_a2 = definitionEntry.furigana) != null ? _a2 : definitionEntry.definition}</span></span>`
|
|
2801
|
-
) : "null";
|
|
2802
|
-
}
|
|
2776
|
+
(definitionEntry, index) => index > 2 ? createEntry(
|
|
2777
|
+
`<span class="word word-definition${definitionEntry.mayNotBeAccurate === 2 ? " mnba2" : definitionEntry.mayNotBeAccurate === 1 ? " mnba1" : ""}"><span class="word word-definition-original">${definitionEntry.definition}</span><span class="word word-definition-furigana">${definitionEntry.furigana ?? definitionEntry.definition}</span></span>`
|
|
2778
|
+
) : "null"
|
|
2803
2779
|
).filter((definition) => definition !== "null").join("")}</details>` : "";
|
|
2804
2780
|
const definitionsField = firstThreeDefinitions !== void 0 ? `${firstThreeDefinitions}${otherDefinitions}` : '<span class="word word-definition">(no definitions)</span>';
|
|
2805
2781
|
fields.push(
|