yomitan-core 1.2.0 → 1.3.0
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/dist/anki.cjs +794 -7
- package/dist/anki.cjs.map +1 -1
- package/dist/anki.d.cts +58 -3
- package/dist/anki.d.cts.map +1 -1
- package/dist/anki.d.ts +58 -3
- package/dist/anki.d.ts.map +1 -1
- package/dist/anki.js +787 -8
- package/dist/anki.js.map +1 -1
- package/dist/{audio-DN-FhZ5k.d.ts → audio-DGGWaBI-.d.ts} +1 -1
- package/dist/{audio-DN-FhZ5k.d.ts.map → audio-DGGWaBI-.d.ts.map} +1 -1
- package/dist/{audio-D9DvYyB7.d.cts → audio-Dvl_3S4i.d.cts} +1 -1
- package/dist/{audio-D9DvYyB7.d.cts.map → audio-Dvl_3S4i.d.cts.map} +1 -1
- package/dist/{audio-url-generator-_6Qk0i3T.js → audio-url-generator-BLuQVkZt.js} +1 -1
- package/dist/{audio-url-generator-_6Qk0i3T.js.map → audio-url-generator-BLuQVkZt.js.map} +1 -1
- package/dist/{audio-url-generator-CZECihX-.cjs → audio-url-generator-BXsug11L.cjs} +1 -1
- package/dist/{audio-url-generator-C7mkxYeq.js → audio-url-generator-CMk_IkiS.js} +1 -1
- package/dist/{audio-url-generator-CorFRyBU.cjs → audio-url-generator-Ca-mSUkC.cjs} +1 -1
- package/dist/{audio-url-generator-CorFRyBU.cjs.map → audio-url-generator-Ca-mSUkC.cjs.map} +1 -1
- package/dist/audio.cjs +1 -1
- package/dist/audio.d.cts +2 -2
- package/dist/audio.d.ts +2 -2
- package/dist/audio.js +1 -1
- package/dist/content-manager-BF1w7O_T.cjs +98 -0
- package/dist/content-manager-BF1w7O_T.cjs.map +1 -0
- package/dist/content-manager-N3C_dYMa.js +73 -0
- package/dist/content-manager-N3C_dYMa.js.map +1 -0
- package/dist/database.d.cts +3 -3
- package/dist/database.d.ts +3 -3
- package/dist/{dictionary-6Gj8AfGC.d.cts → dictionary-D7l-qFt1.d.cts} +2 -2
- package/dist/{dictionary-6Gj8AfGC.d.cts.map → dictionary-D7l-qFt1.d.cts.map} +1 -1
- package/dist/{dictionary-DdxghSJP.d.ts → dictionary-Dalj9Ow7.d.ts} +1 -1
- package/dist/{dictionary-DdxghSJP.d.ts.map → dictionary-Dalj9Ow7.d.ts.map} +1 -1
- package/dist/{dictionary-database-D0lvK2n3.d.ts → dictionary-database-Bu8vYgxF.d.ts} +2 -2
- package/dist/{dictionary-database-D0lvK2n3.d.ts.map → dictionary-database-Bu8vYgxF.d.ts.map} +1 -1
- package/dist/{dictionary-database-3OesNIMt.d.cts → dictionary-database-DoM6-8dq.d.cts} +2 -2
- package/dist/{dictionary-database-3OesNIMt.d.cts.map → dictionary-database-DoM6-8dq.d.cts.map} +1 -1
- package/dist/{dictionary-importer-CDbCAbwG.d.ts → dictionary-importer-CwR3Lanr.d.ts} +2 -2
- package/dist/{dictionary-importer-CDbCAbwG.d.ts.map → dictionary-importer-CwR3Lanr.d.ts.map} +1 -1
- package/dist/{dictionary-importer-CYMaT3qh.d.cts → dictionary-importer-DeeGqQGW.d.cts} +3 -3
- package/dist/{dictionary-importer-CYMaT3qh.d.cts.map → dictionary-importer-DeeGqQGW.d.cts.map} +1 -1
- package/dist/{display-generator-BAEJDrHT.js → display-generator-BbZfIOYp.js} +3 -3
- package/dist/{display-generator-BAEJDrHT.js.map → display-generator-BbZfIOYp.js.map} +1 -1
- package/dist/{display-generator-D5fkD0JI.cjs → display-generator-D6D7sXdF.cjs} +3 -3
- package/dist/{display-generator-D_0chBzj.cjs → display-generator-DtLBrDAy.cjs} +3 -3
- package/dist/{display-generator-D_0chBzj.cjs.map → display-generator-DtLBrDAy.cjs.map} +1 -1
- package/dist/display-generator-aaac7_nH.js +10 -0
- package/dist/import.d.cts +3 -3
- package/dist/import.d.ts +3 -3
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +12 -51
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +12 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/{language-xAbQxgXc.d.cts → language-ByrpD3L4.d.cts} +1 -1
- package/dist/{language-xAbQxgXc.d.cts.map → language-ByrpD3L4.d.cts.map} +1 -1
- package/dist/{language-DMwuc2-C.d.ts → language-C39UEHX_.d.ts} +1 -1
- package/dist/{language-DMwuc2-C.d.ts.map → language-C39UEHX_.d.ts.map} +1 -1
- package/dist/language.d.cts +3 -3
- package/dist/language.d.ts +3 -3
- package/dist/lookup.d.cts +4 -4
- package/dist/lookup.d.ts +4 -4
- package/dist/{multi-language-transformer-CFu0CVWY.d.ts → multi-language-transformer-BXLoH3f2.d.ts} +3 -3
- package/dist/{multi-language-transformer-CFu0CVWY.d.ts.map → multi-language-transformer-BXLoH3f2.d.ts.map} +1 -1
- package/dist/{multi-language-transformer-KEzXdvLB.d.cts → multi-language-transformer-D1zLgp28.d.cts} +3 -3
- package/dist/{multi-language-transformer-KEzXdvLB.d.cts.map → multi-language-transformer-D1zLgp28.d.cts.map} +1 -1
- package/dist/{pronunciation-generator-CP1kjYje.cjs → pronunciation-generator-CCvUgpPJ.cjs} +1 -1
- package/dist/{pronunciation-generator-BXcwS3By.js → pronunciation-generator-CEqH1ZZ0.js} +1 -1
- package/dist/{pronunciation-generator-BXcwS3By.js.map → pronunciation-generator-CEqH1ZZ0.js.map} +1 -1
- package/dist/{pronunciation-generator-CeC3LFPU.cjs → pronunciation-generator-CbwQtlX7.cjs} +1 -1
- package/dist/{pronunciation-generator-CeC3LFPU.cjs.map → pronunciation-generator-CbwQtlX7.cjs.map} +1 -1
- package/dist/{pronunciation-generator-I1xpdJu0.js → pronunciation-generator-DrZMHDZY.js} +1 -1
- package/dist/render.cjs +8 -78
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +2 -2
- package/dist/render.d.ts +2 -2
- package/dist/render.js +4 -74
- package/dist/render.js.map +1 -1
- package/dist/{sentence-parser-BQpu2oSA.d.cts → sentence-parser-BzYE6VPn.d.cts} +3 -3
- package/dist/{sentence-parser-BQpu2oSA.d.cts.map → sentence-parser-BzYE6VPn.d.cts.map} +1 -1
- package/dist/{sentence-parser-CmsHUc_p.d.ts → sentence-parser-CgisSkL5.d.ts} +3 -3
- package/dist/{sentence-parser-CmsHUc_p.d.ts.map → sentence-parser-CgisSkL5.d.ts.map} +1 -1
- package/dist/{core-BUpclilG.d.cts → settings-DIcKLlgX.d.ts} +43 -2
- package/dist/settings-DIcKLlgX.d.ts.map +1 -0
- package/dist/{core-CRjMTF7c.d.ts → settings-joBAbK3e.d.cts} +43 -2
- package/dist/settings-joBAbK3e.d.cts.map +1 -0
- package/dist/{structured-content-generator-gnjtdBcC.js → structured-content-generator-CoIq3j_l.js} +1 -1
- package/dist/{structured-content-generator-gnjtdBcC.js.map → structured-content-generator-CoIq3j_l.js.map} +1 -1
- package/dist/{structured-content-generator-CokLKgrb.cjs → structured-content-generator-D3WOq_vz.cjs} +1 -1
- package/dist/{structured-content-generator-CokLKgrb.cjs.map → structured-content-generator-D3WOq_vz.cjs.map} +1 -1
- package/dist/{structured-content-generator-_z5dJECG.cjs → structured-content-generator-DOgn0FYP.cjs} +1 -1
- package/dist/{structured-content-generator-BhEkwa0T.js → structured-content-generator-DzV-kHxa.js} +1 -1
- package/package.json +2 -1
- package/dist/core-BUpclilG.d.cts.map +0 -1
- package/dist/core-CRjMTF7c.d.ts.map +0 -1
- package/dist/display-generator-DZLMaVuP.js +0 -10
package/dist/anki.cjs
CHANGED
|
@@ -6,7 +6,10 @@ const require_errors = require('./errors-0pIJI6N2.cjs');
|
|
|
6
6
|
const require_dictionary_data_util = require('./dictionary-data-util-DmLJMtGc.cjs');
|
|
7
7
|
require('./json-Cdj6aIOQ.cjs');
|
|
8
8
|
require('./furigana-SZuBaUyl.cjs');
|
|
9
|
+
require('./text-utilities-CTsN1Bq8.cjs');
|
|
9
10
|
const require_anki_connect = require('./anki-connect-DGx7Gr0H.cjs');
|
|
11
|
+
const require_content_manager = require('./content-manager-BF1w7O_T.cjs');
|
|
12
|
+
const require_structured_content_generator = require('./structured-content-generator-D3WOq_vz.cjs');
|
|
10
13
|
|
|
11
14
|
//#region src/anki/anki-note-builder.ts
|
|
12
15
|
/**
|
|
@@ -742,7 +745,7 @@ function getTermDictionaryAliases(dictionaryEntry) {
|
|
|
742
745
|
for (const { dictionaryAlias } of dictionaryEntry.definitions) dictionaryAliases.add(dictionaryAlias);
|
|
743
746
|
return [...dictionaryAliases];
|
|
744
747
|
}
|
|
745
|
-
function getTermDictionaryEntryCommonInfo(dictionaryEntry, type,
|
|
748
|
+
function getTermDictionaryEntryCommonInfo(dictionaryEntry, type, dictionaryStylesMap, _glossaryLayoutMode) {
|
|
746
749
|
const merged = type === "termMerged";
|
|
747
750
|
const hasDefinitions = type !== "term";
|
|
748
751
|
const allTermsSet = new Set();
|
|
@@ -756,6 +759,13 @@ function getTermDictionaryEntryCommonInfo(dictionaryEntry, type, _dictionaryStyl
|
|
|
756
759
|
const definitions = [];
|
|
757
760
|
const definitionTags = [];
|
|
758
761
|
for (const { tags, headwordIndices, entries, dictionary, dictionaryAlias, sequences } of dictionaryEntry.definitions) {
|
|
762
|
+
const dictionaryStyles = dictionaryStylesMap.get(dictionary);
|
|
763
|
+
let glossaryScopedStyles = "";
|
|
764
|
+
let dictScopedStyles = "";
|
|
765
|
+
if (dictionaryStyles) {
|
|
766
|
+
glossaryScopedStyles = addGlossaryScopeToCss(dictionaryStyles);
|
|
767
|
+
dictScopedStyles = addGlossaryScopeToCss(addDictionaryScopeToCss(dictionaryStyles, dictionary));
|
|
768
|
+
}
|
|
759
769
|
const definitionTags2 = [];
|
|
760
770
|
for (const tag of tags) {
|
|
761
771
|
definitionTags.push(convertTag(tag));
|
|
@@ -767,8 +777,8 @@ function getTermDictionaryEntryCommonInfo(dictionaryEntry, type, _dictionaryStyl
|
|
|
767
777
|
sequence: sequences[0],
|
|
768
778
|
dictionary,
|
|
769
779
|
dictionaryAlias,
|
|
770
|
-
glossaryScopedStyles
|
|
771
|
-
dictScopedStyles
|
|
780
|
+
glossaryScopedStyles,
|
|
781
|
+
dictScopedStyles,
|
|
772
782
|
glossary: entries,
|
|
773
783
|
definitionTags: definitionTags2,
|
|
774
784
|
only
|
|
@@ -960,13 +970,29 @@ function getTermGlossaryArray(dictionaryEntry, type) {
|
|
|
960
970
|
}
|
|
961
971
|
return void 0;
|
|
962
972
|
}
|
|
963
|
-
function getTermStyles(dictionaryEntry, type,
|
|
973
|
+
function getTermStyles(dictionaryEntry, type, dictionaryStylesMap) {
|
|
964
974
|
if (type !== "term") return void 0;
|
|
975
|
+
let glossaryScopedStyles = "";
|
|
976
|
+
let dictScopedStyles = "";
|
|
977
|
+
for (const { dictionary } of dictionaryEntry.definitions) {
|
|
978
|
+
const dictionaryStyles = dictionaryStylesMap.get(dictionary);
|
|
979
|
+
if (dictionaryStyles) {
|
|
980
|
+
glossaryScopedStyles += addGlossaryScopeToCss(dictionaryStyles);
|
|
981
|
+
dictScopedStyles += addGlossaryScopeToCss(addDictionaryScopeToCss(dictionaryStyles, dictionary));
|
|
982
|
+
}
|
|
983
|
+
}
|
|
965
984
|
return {
|
|
966
|
-
glossaryScopedStyles
|
|
967
|
-
dictScopedStyles
|
|
985
|
+
glossaryScopedStyles,
|
|
986
|
+
dictScopedStyles
|
|
968
987
|
};
|
|
969
988
|
}
|
|
989
|
+
function addGlossaryScopeToCss(css) {
|
|
990
|
+
return require_content_manager.addScopeToCssLegacy(css, ".yomitan-glossary");
|
|
991
|
+
}
|
|
992
|
+
function addDictionaryScopeToCss(css, dictionaryTitle) {
|
|
993
|
+
const escapedTitle = dictionaryTitle.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
994
|
+
return require_content_manager.addScopeToCssLegacy(css, `[data-dictionary="${escapedTitle}"]`);
|
|
995
|
+
}
|
|
970
996
|
function getTermTags(dictionaryEntry, type) {
|
|
971
997
|
if (type !== "termMerged") {
|
|
972
998
|
const results = [];
|
|
@@ -1303,6 +1329,7 @@ var AnkiTemplateRenderer = class {
|
|
|
1303
1329
|
_stateStack;
|
|
1304
1330
|
_requirements;
|
|
1305
1331
|
_cleanupCallbacks;
|
|
1332
|
+
_document;
|
|
1306
1333
|
_handlebars;
|
|
1307
1334
|
constructor(handlebars) {
|
|
1308
1335
|
this._handlebars = handlebars;
|
|
@@ -1311,6 +1338,7 @@ var AnkiTemplateRenderer = class {
|
|
|
1311
1338
|
this._stateStack = null;
|
|
1312
1339
|
this._requirements = null;
|
|
1313
1340
|
this._cleanupCallbacks = [];
|
|
1341
|
+
this._document = typeof document !== "undefined" ? document : null;
|
|
1314
1342
|
}
|
|
1315
1343
|
/**
|
|
1316
1344
|
* Gets the core TemplateRenderer instance.
|
|
@@ -1345,6 +1373,7 @@ var AnkiTemplateRenderer = class {
|
|
|
1345
1373
|
["concat", this._concat.bind(this)],
|
|
1346
1374
|
["pitchCategories", this._pitchCategories.bind(this)],
|
|
1347
1375
|
["formatGlossary", this._formatGlossary.bind(this)],
|
|
1376
|
+
["formatGlossaryPlain", this._formatGlossaryPlain.bind(this)],
|
|
1348
1377
|
["hasMedia", this._hasMedia.bind(this)],
|
|
1349
1378
|
["getMedia", this._getMedia.bind(this)],
|
|
1350
1379
|
["hiragana", this._hiragana.bind(this)],
|
|
@@ -1661,10 +1690,69 @@ var AnkiTemplateRenderer = class {
|
|
|
1661
1690
|
switch (content.type) {
|
|
1662
1691
|
case "text": return this._safeString(this._stringToMultiLineHtml(content.text));
|
|
1663
1692
|
case "image": return "";
|
|
1664
|
-
case "structured-content": return this._safeString(
|
|
1693
|
+
case "structured-content": return this._safeString(this._formatStructuredContent(content, _dictionary));
|
|
1665
1694
|
}
|
|
1666
1695
|
return "";
|
|
1667
1696
|
}
|
|
1697
|
+
_formatGlossaryPlain(args) {
|
|
1698
|
+
const [_dictionary, content] = args;
|
|
1699
|
+
if (typeof content === "string") return this._safeString(content);
|
|
1700
|
+
if (!(typeof content === "object" && content !== null)) return "";
|
|
1701
|
+
switch (content.type) {
|
|
1702
|
+
case "text": return this._safeString(content.text);
|
|
1703
|
+
case "image": return "";
|
|
1704
|
+
case "structured-content": return this._safeString(this._extractStructuredContentText(content.content));
|
|
1705
|
+
}
|
|
1706
|
+
return "";
|
|
1707
|
+
}
|
|
1708
|
+
_formatStructuredContent(content, dictionary) {
|
|
1709
|
+
const node = this._createStructuredContentNode(content.content, dictionary);
|
|
1710
|
+
if (node === null) return this._stringToMultiLineHtml(this._extractStructuredContentText(content.content));
|
|
1711
|
+
return this._getNodeHtml(node);
|
|
1712
|
+
}
|
|
1713
|
+
_createStructuredContentNode(content, dictionary) {
|
|
1714
|
+
if (this._document === null) return null;
|
|
1715
|
+
const generator = new require_structured_content_generator.StructuredContentGenerator(new require_content_manager.NoOpContentManager(), this._document);
|
|
1716
|
+
return generator.createStructuredContent(content, dictionary);
|
|
1717
|
+
}
|
|
1718
|
+
_getNodeHtml(node) {
|
|
1719
|
+
if (this._document === null) return "";
|
|
1720
|
+
const container = this._document.createElement("div");
|
|
1721
|
+
container.appendChild(node);
|
|
1722
|
+
return container.innerHTML;
|
|
1723
|
+
}
|
|
1724
|
+
_extractStructuredContentText(content) {
|
|
1725
|
+
const text = this._extractStructuredContentTextParts(content).join("");
|
|
1726
|
+
return text.replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").replace(/[ \t]{2,}/g, " ").trim();
|
|
1727
|
+
}
|
|
1728
|
+
_extractStructuredContentTextParts(content) {
|
|
1729
|
+
if (typeof content === "string") return [content];
|
|
1730
|
+
if (Array.isArray(content)) {
|
|
1731
|
+
const parts = [];
|
|
1732
|
+
for (const item of content) parts.push(...this._extractStructuredContentTextParts(item));
|
|
1733
|
+
return parts;
|
|
1734
|
+
}
|
|
1735
|
+
if (!(typeof content === "object" && content !== null)) return [];
|
|
1736
|
+
if (content.tag === "br") return ["\n"];
|
|
1737
|
+
if (content.tag === "rt" || content.tag === "rp") return [];
|
|
1738
|
+
const inner = typeof content.content !== "undefined" ? this._extractStructuredContentTextParts(content.content) : [];
|
|
1739
|
+
switch (content.tag) {
|
|
1740
|
+
case "li": return [...inner, "\n"];
|
|
1741
|
+
case "td":
|
|
1742
|
+
case "th": return [...inner, " "];
|
|
1743
|
+
case "div":
|
|
1744
|
+
case "ol":
|
|
1745
|
+
case "ul":
|
|
1746
|
+
case "table":
|
|
1747
|
+
case "thead":
|
|
1748
|
+
case "tbody":
|
|
1749
|
+
case "tfoot":
|
|
1750
|
+
case "tr":
|
|
1751
|
+
case "details":
|
|
1752
|
+
case "summary": return [...inner, "\n"];
|
|
1753
|
+
default: return inner;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1668
1756
|
_hasMedia(args, _context, options) {
|
|
1669
1757
|
const data = this._getNoteDataFromOptions(options);
|
|
1670
1758
|
return this._mediaProvider.hasMedia(data, args, options.hash);
|
|
@@ -1748,12 +1836,711 @@ function getPitchCategory(reading, positions, isVerbOrAdjective) {
|
|
|
1748
1836
|
return isVerbOrAdjective ? "kifuku" : "nakadaka";
|
|
1749
1837
|
}
|
|
1750
1838
|
|
|
1839
|
+
//#endregion
|
|
1840
|
+
//#region src/anki/default-anki-field-templates.ts
|
|
1841
|
+
const DEFAULT_ANKI_FIELD_TEMPLATES = String.raw`
|
|
1842
|
+
{{#*inline "glossary-single"}}
|
|
1843
|
+
{{~#unless brief~}}
|
|
1844
|
+
{{~#scope~}}
|
|
1845
|
+
{{~set "any" false~}}
|
|
1846
|
+
{{~#each definitionTags~}}
|
|
1847
|
+
{{~#if (op "||" (op "!" @root.compactTags) (op "!" redundant))~}}
|
|
1848
|
+
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
1849
|
+
{{name}}
|
|
1850
|
+
{{~set "any" true~}}
|
|
1851
|
+
{{~/if~}}
|
|
1852
|
+
{{~/each~}}
|
|
1853
|
+
{{~#unless noDictionaryTag~}}
|
|
1854
|
+
{{~#if (op "||" (op "!" @root.compactTags) (op "!==" dictionary (get "previousDictionary")))~}}
|
|
1855
|
+
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
1856
|
+
{{dictionaryAlias}}
|
|
1857
|
+
{{~set "any" true~}}
|
|
1858
|
+
{{~/if~}}
|
|
1859
|
+
{{~/unless~}}
|
|
1860
|
+
{{~#if (get "any")}})</i> {{/if~}}
|
|
1861
|
+
{{~/scope~}}
|
|
1862
|
+
{{~#if only~}}({{#each only}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} only) {{/if~}}
|
|
1863
|
+
{{~/unless~}}
|
|
1864
|
+
{{~#if (op "<=" glossary.length 1)~}}
|
|
1865
|
+
{{#each glossary}}{{formatGlossary ../dictionary .}}{{/each}}
|
|
1866
|
+
{{~else if @root.compactGlossaries~}}
|
|
1867
|
+
{{#each glossary}}{{formatGlossary ../dictionary .}}{{#unless @last}} | {{/unless}}{{/each}}
|
|
1868
|
+
{{~else~}}
|
|
1869
|
+
<ul>{{#each glossary}}<li>{{formatGlossary ../dictionary .}}</li>{{/each}}</ul>
|
|
1870
|
+
{{~/if~}}
|
|
1871
|
+
{{~set "previousDictionary" dictionary~}}
|
|
1872
|
+
{{/inline}}
|
|
1873
|
+
|
|
1874
|
+
{{#*inline "audio"}}
|
|
1875
|
+
{{~#if (hasMedia "audio")~}}
|
|
1876
|
+
[sound:{{getMedia "audio"}}]
|
|
1877
|
+
{{~/if~}}
|
|
1878
|
+
{{/inline}}
|
|
1879
|
+
|
|
1880
|
+
{{#*inline "character"}}
|
|
1881
|
+
{{~definition.character~}}
|
|
1882
|
+
{{/inline}}
|
|
1883
|
+
|
|
1884
|
+
{{#*inline "dictionary"}}
|
|
1885
|
+
{{~definition.dictionary~}}
|
|
1886
|
+
{{/inline}}
|
|
1887
|
+
|
|
1888
|
+
{{#*inline "dictionary-alias"}}
|
|
1889
|
+
{{~definition.dictionaryAlias~}}
|
|
1890
|
+
{{/inline}}
|
|
1891
|
+
|
|
1892
|
+
{{#*inline "expression"}}
|
|
1893
|
+
{{~#if merge~}}
|
|
1894
|
+
{{~#each definition.expression~}}
|
|
1895
|
+
{{{.}}}
|
|
1896
|
+
{{~#unless @last}}、{{/unless~}}
|
|
1897
|
+
{{~/each~}}
|
|
1898
|
+
{{~else~}}
|
|
1899
|
+
{{definition.expression}}
|
|
1900
|
+
{{~/if~}}
|
|
1901
|
+
{{/inline}}
|
|
1902
|
+
|
|
1903
|
+
{{#*inline "furigana"}}
|
|
1904
|
+
{{~#if merge~}}
|
|
1905
|
+
{{~#each definition.expressions~}}
|
|
1906
|
+
<span class="expression-{{termFrequency}}">{{~furigana .~}}</span>
|
|
1907
|
+
{{~#unless @last}}、{{/unless~}}
|
|
1908
|
+
{{~/each~}}
|
|
1909
|
+
{{~else~}}
|
|
1910
|
+
{{furigana definition}}
|
|
1911
|
+
{{~/if~}}
|
|
1912
|
+
{{/inline}}
|
|
1913
|
+
|
|
1914
|
+
{{#*inline "furigana-plain"}}
|
|
1915
|
+
{{~#if merge~}}
|
|
1916
|
+
{{~#each definition.expressions~}}
|
|
1917
|
+
<span class="expression-{{termFrequency}}">{{~furiganaPlain .~}}</span>
|
|
1918
|
+
{{~#unless @last}}、{{/unless~}}
|
|
1919
|
+
{{~/each~}}
|
|
1920
|
+
{{~else~}}
|
|
1921
|
+
{{furiganaPlain definition}}
|
|
1922
|
+
{{~/if~}}
|
|
1923
|
+
{{/inline}}
|
|
1924
|
+
|
|
1925
|
+
{{~#*inline "glossary"~}}
|
|
1926
|
+
<div style="text-align: left;" class="yomitan-glossary">
|
|
1927
|
+
{{~#scope~}}
|
|
1928
|
+
{{~#if (op "===" definition.type "term")~}}
|
|
1929
|
+
{{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}}
|
|
1930
|
+
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
|
|
1931
|
+
{{~#if definition.glossaryScopedStyles~}}
|
|
1932
|
+
<style>{{{definition.glossaryScopedStyles}}}</style>
|
|
1933
|
+
{{~/if~}}
|
|
1934
|
+
{{~/unless~}}
|
|
1935
|
+
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
|
|
1936
|
+
<ol>
|
|
1937
|
+
{{~#each definition.definitions~}}
|
|
1938
|
+
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
|
|
1939
|
+
<li data-dictionary="{{dictionary}}">
|
|
1940
|
+
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
|
|
1941
|
+
</li>
|
|
1942
|
+
{{~#if dictScopedStyles~}}
|
|
1943
|
+
<style>{{{dictScopedStyles}}}</style>
|
|
1944
|
+
{{~/if~}}
|
|
1945
|
+
{{~/unless~}}
|
|
1946
|
+
{{~/each~}}
|
|
1947
|
+
</ol>
|
|
1948
|
+
{{~else if (op "===" definition.type "kanji")~}}
|
|
1949
|
+
{{~#if (op ">" definition.glossary.length 1)~}}
|
|
1950
|
+
<ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
|
|
1951
|
+
{{~else~}}
|
|
1952
|
+
{{~#each definition.glossary~}}{{.}}{{~/each~}}
|
|
1953
|
+
{{~/if~}}
|
|
1954
|
+
{{~/if~}}
|
|
1955
|
+
{{~/scope~}}
|
|
1956
|
+
</div>
|
|
1957
|
+
{{~/inline~}}
|
|
1958
|
+
|
|
1959
|
+
{{#*inline "glossary-no-dictionary"}}
|
|
1960
|
+
{{~> glossary noDictionaryTag=true ~}}
|
|
1961
|
+
{{/inline}}
|
|
1962
|
+
|
|
1963
|
+
{{#*inline "glossary-brief"}}
|
|
1964
|
+
{{~> glossary brief=true ~}}
|
|
1965
|
+
{{/inline}}
|
|
1966
|
+
|
|
1967
|
+
{{~#*inline "glossary-plain"~}}
|
|
1968
|
+
{{~#scope~}}
|
|
1969
|
+
{{~#if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
|
|
1970
|
+
{{~#each definition.definitions~}}
|
|
1971
|
+
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
|
|
1972
|
+
{{~#unless ../noDictionaryTag~}}
|
|
1973
|
+
({{dictionaryAlias}})<br>
|
|
1974
|
+
{{~/unless~}}
|
|
1975
|
+
{{#each glossary}}{{{formatGlossaryPlain ../dictionary .}}}{{#unless @last}}<br>{{/unless}}{{/each}}{{#unless @last}}<br>{{/unless}}
|
|
1976
|
+
{{~/unless~}}
|
|
1977
|
+
{{~/each~}}
|
|
1978
|
+
{{~else~}}
|
|
1979
|
+
{{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}}
|
|
1980
|
+
{{~#unless noDictionaryTag~}}
|
|
1981
|
+
({{definition.dictionaryAlias}})<br>
|
|
1982
|
+
{{~/unless~}}
|
|
1983
|
+
{{#each definition.glossary}}{{{formatGlossaryPlain ../definition.dictionary .}}}{{/each}}
|
|
1984
|
+
{{~/unless~}}
|
|
1985
|
+
{{~/if~}}
|
|
1986
|
+
{{~/scope~}}
|
|
1987
|
+
{{~/inline~}}
|
|
1988
|
+
|
|
1989
|
+
{{#*inline "glossary-plain-no-dictionary"~}}
|
|
1990
|
+
{{~> glossary-plain noDictionaryTag=true ~}}
|
|
1991
|
+
{{/inline}}
|
|
1992
|
+
|
|
1993
|
+
{{~#*inline "glossary-first"~}}
|
|
1994
|
+
<div style="text-align: left;" class="yomitan-glossary">
|
|
1995
|
+
{{~#scope~}}
|
|
1996
|
+
{{~#if (op "===" definition.type "term")~}}
|
|
1997
|
+
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
|
|
1998
|
+
{{~#if definition.glossaryScopedStyles~}}
|
|
1999
|
+
<style>{{{definition.glossaryScopedStyles}}}</style>
|
|
2000
|
+
{{~/if~}}
|
|
2001
|
+
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
|
|
2002
|
+
{{~#if (op ">" definition.definitions.length 1)~}}
|
|
2003
|
+
{{~#with definition.definitions.[0]~}}
|
|
2004
|
+
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
|
|
2005
|
+
{{~#if glossaryScopedStyles~}}
|
|
2006
|
+
<style>{{{glossaryScopedStyles}}}</style>
|
|
2007
|
+
{{~/if~}}
|
|
2008
|
+
{{~/with~}}
|
|
2009
|
+
{{~else~}}
|
|
2010
|
+
{{~#with definition.definitions.[0]~}}
|
|
2011
|
+
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
|
|
2012
|
+
{{~#if glossaryScopedStyles~}}
|
|
2013
|
+
<style>{{{glossaryScopedStyles}}}</style>
|
|
2014
|
+
{{~/if~}}
|
|
2015
|
+
{{~/with~}}
|
|
2016
|
+
{{~/if~}}
|
|
2017
|
+
{{~/if~}}
|
|
2018
|
+
{{~/scope~}}
|
|
2019
|
+
</div>
|
|
2020
|
+
{{~/inline~}}
|
|
2021
|
+
|
|
2022
|
+
{{#*inline "glossary-first-no-dictionary"}}
|
|
2023
|
+
{{~> glossary-first noDictionaryTag=true ~}}
|
|
2024
|
+
{{/inline}}
|
|
2025
|
+
|
|
2026
|
+
{{#*inline "glossary-first-brief"}}
|
|
2027
|
+
{{~> glossary-first brief=true ~}}
|
|
2028
|
+
{{/inline}}
|
|
2029
|
+
|
|
2030
|
+
{{#*inline "kunyomi"}}
|
|
2031
|
+
{{~#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}}
|
|
2032
|
+
{{/inline}}
|
|
2033
|
+
|
|
2034
|
+
{{#*inline "onyomi"}}
|
|
2035
|
+
{{~#each definition.onyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}}
|
|
2036
|
+
{{/inline}}
|
|
2037
|
+
|
|
2038
|
+
{{#*inline "onyomi-hiragana"}}
|
|
2039
|
+
{{~#each definition.onyomi}}{{hiragana .}}{{#unless @last}}, {{/unless}}{{/each~}}
|
|
2040
|
+
{{/inline}}
|
|
2041
|
+
|
|
2042
|
+
{{#*inline "reading"}}
|
|
2043
|
+
{{~#if merge~}}
|
|
2044
|
+
{{~#each definition.reading~}}
|
|
2045
|
+
{{{.}}}
|
|
2046
|
+
{{~#unless @last}}、{{/unless~}}
|
|
2047
|
+
{{~/each~}}
|
|
2048
|
+
{{~else~}}
|
|
2049
|
+
{{~definition.reading~}}
|
|
2050
|
+
{{~/if~}}
|
|
2051
|
+
{{/inline}}
|
|
2052
|
+
|
|
2053
|
+
{{#*inline "sentence"}}
|
|
2054
|
+
{{~#if definition.cloze}}{{{definition.cloze.sentence}}}{{/if~}}
|
|
2055
|
+
{{/inline}}
|
|
2056
|
+
|
|
2057
|
+
{{#*inline "cloze-prefix"}}
|
|
2058
|
+
{{~#if definition.cloze}}{{{definition.cloze.prefix}}}{{/if~}}
|
|
2059
|
+
{{/inline}}
|
|
2060
|
+
|
|
2061
|
+
{{#*inline "cloze-body"}}
|
|
2062
|
+
{{~#if definition.cloze}}{{{definition.cloze.body}}}{{/if~}}
|
|
2063
|
+
{{/inline}}
|
|
2064
|
+
|
|
2065
|
+
{{#*inline "cloze-body-kana"}}
|
|
2066
|
+
{{~#if definition.cloze}}{{{definition.cloze.bodyKana}}}{{/if~}}
|
|
2067
|
+
{{/inline}}
|
|
2068
|
+
|
|
2069
|
+
{{#*inline "cloze-suffix"}}
|
|
2070
|
+
{{~#if definition.cloze}}{{{definition.cloze.suffix}}}{{/if~}}
|
|
2071
|
+
{{/inline}}
|
|
2072
|
+
|
|
2073
|
+
{{#*inline "tags"}}
|
|
2074
|
+
{{~#mergeTags definition group merge}}{{this}}{{/mergeTags~}}
|
|
2075
|
+
{{/inline}}
|
|
2076
|
+
|
|
2077
|
+
{{~#*inline "url"~}}
|
|
2078
|
+
<a href="{{definition.url}}">{{definition.url}}</a>
|
|
2079
|
+
{{~/inline~}}
|
|
2080
|
+
|
|
2081
|
+
{{#*inline "screenshot"}}
|
|
2082
|
+
{{~#if (hasMedia "screenshot")~}}
|
|
2083
|
+
<img src="{{getMedia "screenshot"}}" />
|
|
2084
|
+
{{~/if~}}
|
|
2085
|
+
{{/inline}}
|
|
2086
|
+
|
|
2087
|
+
{{#*inline "document-title"}}
|
|
2088
|
+
{{~context.document.title~}}
|
|
2089
|
+
{{/inline}}
|
|
2090
|
+
|
|
2091
|
+
{{! Pitch Accents }}
|
|
2092
|
+
{{#*inline "pitch-accent-item"}}
|
|
2093
|
+
{{~pronunciation format=format reading=reading pitchPositions=positions nasalPositions=nasalPositions devoicePositions=devoicePositions~}}
|
|
2094
|
+
{{/inline}}
|
|
2095
|
+
|
|
2096
|
+
{{#*inline "pitch-accent-item-disambiguation"}}
|
|
2097
|
+
{{~#scope~}}
|
|
2098
|
+
{{~set "exclusive" (spread exclusiveExpressions exclusiveReadings)~}}
|
|
2099
|
+
{{~#if (op ">" (property (get "exclusive") "length") 0)~}}
|
|
2100
|
+
{{~set "separator" ""~}}
|
|
2101
|
+
<em>({{#each (get "exclusive")~}}
|
|
2102
|
+
{{~get "separator"~}}{{{.}}}
|
|
2103
|
+
{{~/each}} only) </em>
|
|
2104
|
+
{{~/if~}}
|
|
2105
|
+
{{~/scope~}}
|
|
2106
|
+
{{/inline}}
|
|
2107
|
+
|
|
2108
|
+
{{#*inline "pitch-accent-list"}}
|
|
2109
|
+
{{~#if (op ">" pitchCount 0)~}}
|
|
2110
|
+
{{~#if (op ">" pitchCount 1)~}}<ol>{{~/if~}}
|
|
2111
|
+
{{~#each pitches~}}
|
|
2112
|
+
{{~#each pitches~}}
|
|
2113
|
+
{{~#if (op ">" ../../pitchCount 1)~}}<li>{{~/if~}}
|
|
2114
|
+
{{~> pitch-accent-item-disambiguation~}}
|
|
2115
|
+
{{~> pitch-accent-item format=../../format~}}
|
|
2116
|
+
{{~#if (op ">" ../../pitchCount 1)~}}</li>{{~/if~}}
|
|
2117
|
+
{{~/each~}}
|
|
2118
|
+
{{~/each~}}
|
|
2119
|
+
{{~#if (op ">" pitchCount 1)~}}</ol>{{~/if~}}
|
|
2120
|
+
{{~/if~}}
|
|
2121
|
+
{{/inline}}
|
|
2122
|
+
|
|
2123
|
+
{{#*inline "pitch-accents"}}
|
|
2124
|
+
{{~> pitch-accent-list format='text'~}}
|
|
2125
|
+
{{/inline}}
|
|
2126
|
+
|
|
2127
|
+
{{#*inline "pitch-accent-graphs"}}
|
|
2128
|
+
{{~> pitch-accent-list format='graph'~}}
|
|
2129
|
+
{{/inline}}
|
|
2130
|
+
|
|
2131
|
+
{{#*inline "pitch-accent-graphs-jj"}}
|
|
2132
|
+
{{~> pitch-accent-list format='graph-jj'~}}
|
|
2133
|
+
{{/inline}}
|
|
2134
|
+
|
|
2135
|
+
{{#*inline "pitch-accent-positions"}}
|
|
2136
|
+
{{~> pitch-accent-list format='position'~}}
|
|
2137
|
+
{{/inline}}
|
|
2138
|
+
|
|
2139
|
+
{{~#*inline "pitch-accent-categories"~}}
|
|
2140
|
+
{{~#each (pitchCategories @root)~}}{{~.~}}{{~#unless @last~}},{{~/unless~}}{{~/each~}}
|
|
2141
|
+
{{~/inline~}}
|
|
2142
|
+
{{! End Pitch Accents }}
|
|
2143
|
+
|
|
2144
|
+
{{#*inline "phonetic-transcriptions"}}
|
|
2145
|
+
{{~#if (op ">" definition.phoneticTranscriptions.length 0)~}}
|
|
2146
|
+
<ul>
|
|
2147
|
+
{{~#each definition.phoneticTranscriptions~}}
|
|
2148
|
+
{{~#each phoneticTranscriptions~}}
|
|
2149
|
+
<li class="pronunciation" data-pronunciation-type="phonetic-transcription">
|
|
2150
|
+
{{~set "any" false~}}
|
|
2151
|
+
{{~#each tags~}}
|
|
2152
|
+
{{~#if (get "any")}}, {{else}}<i>({{/if~}}
|
|
2153
|
+
<span class="tag" data-details="{{name}}">{{name}}</span>
|
|
2154
|
+
{{~set "any" true~}}
|
|
2155
|
+
{{~/each~}}
|
|
2156
|
+
{{~#if (get "any")}})</i> {{/if~}}
|
|
2157
|
+
{{ipa~}}
|
|
2158
|
+
</li>
|
|
2159
|
+
{{~/each~}}
|
|
2160
|
+
{{~/each~}}
|
|
2161
|
+
</ul>
|
|
2162
|
+
{{~/if~}}
|
|
2163
|
+
{{/inline}}
|
|
2164
|
+
|
|
2165
|
+
{{#*inline "clipboard-image"}}
|
|
2166
|
+
{{~#if (hasMedia "clipboardImage")~}}
|
|
2167
|
+
<img src="{{getMedia "clipboardImage"}}" />
|
|
2168
|
+
{{~/if~}}
|
|
2169
|
+
{{/inline}}
|
|
2170
|
+
|
|
2171
|
+
{{#*inline "clipboard-text"}}
|
|
2172
|
+
{{~#if (hasMedia "clipboardText")}}{{{getMedia "clipboardText"}}}{{/if~}}
|
|
2173
|
+
{{/inline}}
|
|
2174
|
+
|
|
2175
|
+
{{#*inline "conjugation"}}
|
|
2176
|
+
{{~#if (op ">" definition.inflectionRuleChainCandidates.length 0)~}}
|
|
2177
|
+
{{~set "multiple" false~}}
|
|
2178
|
+
{{~#if (op ">" definition.inflectionRuleChainCandidates.length 1)~}}
|
|
2179
|
+
{{~set "multiple" true~}}
|
|
2180
|
+
{{~/if~}}
|
|
2181
|
+
{{~#if (get "multiple")~}}<ul>{{/if~}}
|
|
2182
|
+
{{~#each definition.inflectionRuleChainCandidates~}}
|
|
2183
|
+
{{~#if (op ">" inflectionRules.length 0)~}}
|
|
2184
|
+
{{~#if (get "multiple")~}}<li>{{/if~}}
|
|
2185
|
+
{{~#each inflectionRules~}}
|
|
2186
|
+
{{~#if (op ">" @index 0)}} « {{/if~}}
|
|
2187
|
+
{{name}}
|
|
2188
|
+
{{~/each~}}
|
|
2189
|
+
{{~#if (get "multiple")~}}</li>{{/if~}}
|
|
2190
|
+
{{~/if~}}
|
|
2191
|
+
{{~/each~}}
|
|
2192
|
+
{{~#if (get "multiple")~}}</ul>{{/if~}}
|
|
2193
|
+
{{~/if~}}
|
|
2194
|
+
{{/inline}}
|
|
2195
|
+
|
|
2196
|
+
{{#*inline "frequencies"}}
|
|
2197
|
+
{{~#if (op ">" definition.frequencies.length 0)~}}
|
|
2198
|
+
<ul style="text-align: left;">
|
|
2199
|
+
{{~#each definition.frequencies~}}
|
|
2200
|
+
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
|
|
2201
|
+
<li>
|
|
2202
|
+
{{~#if (op "!==" ../definition.type "kanji")~}}
|
|
2203
|
+
{{~#if (op "||" (op ">" ../uniqueExpressions.length 1) (op ">" ../uniqueReadings.length 1))~}}(
|
|
2204
|
+
{{~furigana expression reading~}}
|
|
2205
|
+
) {{/if~}}
|
|
2206
|
+
{{~/if~}}
|
|
2207
|
+
{{~dictionaryAlias}}: {{frequency~}}
|
|
2208
|
+
</li>
|
|
2209
|
+
{{~/unless~}}
|
|
2210
|
+
{{~/each~}}
|
|
2211
|
+
</ul>
|
|
2212
|
+
{{~/if~}}
|
|
2213
|
+
{{/inline}}
|
|
2214
|
+
|
|
2215
|
+
{{#*inline "single-frequency-number"}}
|
|
2216
|
+
{{~#if (op ">" definition.frequencyNumbers.length 0)~}}
|
|
2217
|
+
{{~#each definition.frequencyNumbers~}}
|
|
2218
|
+
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
|
|
2219
|
+
{{frequency~}}
|
|
2220
|
+
{{~/unless~}}
|
|
2221
|
+
{{~/each~}}
|
|
2222
|
+
{{/if}}
|
|
2223
|
+
{{/inline}}
|
|
2224
|
+
|
|
2225
|
+
{{#*inline "frequency-harmonic-rank"}}
|
|
2226
|
+
{{~#if (op "===" definition.frequencyHarmonic -1) ~}}
|
|
2227
|
+
9999999
|
|
2228
|
+
{{~else ~}}
|
|
2229
|
+
{{definition.frequencyHarmonic}}
|
|
2230
|
+
{{~/if~}}
|
|
2231
|
+
{{/inline}}
|
|
2232
|
+
|
|
2233
|
+
{{#*inline "frequency-harmonic-occurrence"}}
|
|
2234
|
+
{{~#if (op "===" definition.frequencyHarmonic -1) ~}}
|
|
2235
|
+
0
|
|
2236
|
+
{{~else ~}}
|
|
2237
|
+
{{definition.frequencyHarmonic}}
|
|
2238
|
+
{{~/if~}}
|
|
2239
|
+
{{/inline}}
|
|
2240
|
+
|
|
2241
|
+
{{#*inline "frequency-average-rank"}}
|
|
2242
|
+
{{~#if (op "===" definition.frequencyAverage -1) ~}}
|
|
2243
|
+
9999999
|
|
2244
|
+
{{~else ~}}
|
|
2245
|
+
{{definition.frequencyAverage}}
|
|
2246
|
+
{{~/if~}}
|
|
2247
|
+
{{/inline}}
|
|
2248
|
+
|
|
2249
|
+
{{#*inline "frequency-average-occurrence"}}
|
|
2250
|
+
{{~#if (op "===" definition.frequencyAverage -1) ~}}
|
|
2251
|
+
0
|
|
2252
|
+
{{~else ~}}
|
|
2253
|
+
{{definition.frequencyAverage}}
|
|
2254
|
+
{{~/if~}}
|
|
2255
|
+
{{/inline}}
|
|
2256
|
+
|
|
2257
|
+
{{#*inline "stroke-count"}}
|
|
2258
|
+
{{~#scope~}}
|
|
2259
|
+
{{~set "found" false~}}
|
|
2260
|
+
{{~#each definition.stats.misc~}}
|
|
2261
|
+
{{~#if (op "===" name "strokes")~}}
|
|
2262
|
+
{{~set "found" true~}}
|
|
2263
|
+
Stroke count: {{value}}
|
|
2264
|
+
{{~/if~}}
|
|
2265
|
+
{{~/each~}}
|
|
2266
|
+
{{~#if (op "!" (get "found"))~}}
|
|
2267
|
+
Stroke count: Unknown
|
|
2268
|
+
{{~/if~}}
|
|
2269
|
+
{{~/scope~}}
|
|
2270
|
+
{{/inline}}
|
|
2271
|
+
|
|
2272
|
+
{{#*inline "part-of-speech-pretty"}}
|
|
2273
|
+
{{~#if (op "===" . "v1")~}}Ichidan verb
|
|
2274
|
+
{{~else if (op "===" . "v5")~}}Godan verb
|
|
2275
|
+
{{~else if (op "===" . "vk")~}}Kuru verb
|
|
2276
|
+
{{~else if (op "===" . "vs")~}}Suru verb
|
|
2277
|
+
{{~else if (op "===" . "vz")~}}Zuru verb
|
|
2278
|
+
{{~else if (op "===" . "adj-i")~}}I-adjective
|
|
2279
|
+
{{~else if (op "===" . "n")~}}Noun
|
|
2280
|
+
{{~else~}}{{.}}
|
|
2281
|
+
{{~/if~}}
|
|
2282
|
+
{{/inline}}
|
|
2283
|
+
|
|
2284
|
+
{{#*inline "part-of-speech"}}
|
|
2285
|
+
{{~#scope~}}
|
|
2286
|
+
{{~#if (op "!==" definition.type "kanji")~}}
|
|
2287
|
+
{{~set "first" true~}}
|
|
2288
|
+
{{~#each definition.expressions~}}
|
|
2289
|
+
{{~#each wordClasses~}}
|
|
2290
|
+
{{~#unless (get (concat "used_" .))~}}
|
|
2291
|
+
{{~> part-of-speech-pretty . ~}}
|
|
2292
|
+
{{~#unless (get "first")}}, {{/unless~}}
|
|
2293
|
+
{{~set (concat "used_" .) true~}}
|
|
2294
|
+
{{~set "first" false~}}
|
|
2295
|
+
{{~/unless~}}
|
|
2296
|
+
{{~/each~}}
|
|
2297
|
+
{{~/each~}}
|
|
2298
|
+
{{~#if (get "first")~}}Unknown{{~/if~}}
|
|
2299
|
+
{{~/if~}}
|
|
2300
|
+
{{~/scope~}}
|
|
2301
|
+
{{/inline}}
|
|
2302
|
+
|
|
2303
|
+
{{#*inline "search-query"}}
|
|
2304
|
+
{{~#multiLine}}{{context.fullQuery}}{{/multiLine~}}
|
|
2305
|
+
{{/inline}}
|
|
2306
|
+
|
|
2307
|
+
{{#*inline "popup-selection-text"}}
|
|
2308
|
+
{{~#if (hasMedia "popupSelectionText")}}{{{getMedia "popupSelectionText"}}}{{/if~}}
|
|
2309
|
+
{{/inline}}
|
|
2310
|
+
|
|
2311
|
+
{{#*inline "sentence-furigana"}}
|
|
2312
|
+
{{~#if definition.cloze~}}
|
|
2313
|
+
{{~#if (hasMedia "textFurigana" definition.cloze.sentence)~}}
|
|
2314
|
+
{{{getMedia "textFurigana" definition.cloze.sentence escape=false}}}
|
|
2315
|
+
{{~else~}}
|
|
2316
|
+
{{{definition.cloze.sentence}}}
|
|
2317
|
+
{{~/if~}}
|
|
2318
|
+
{{~/if~}}
|
|
2319
|
+
{{/inline}}
|
|
2320
|
+
|
|
2321
|
+
{{#*inline "sentence-furigana-plain"}}
|
|
2322
|
+
{{~#if definition.cloze~}}
|
|
2323
|
+
{{~#if (hasMedia "textFuriganaPlain" definition.cloze.sentence)~}}
|
|
2324
|
+
{{{getMedia "textFuriganaPlain" definition.cloze.sentence escape=false}}}
|
|
2325
|
+
{{~else~}}
|
|
2326
|
+
{{{definition.cloze.sentence}}}
|
|
2327
|
+
{{~/if~}}
|
|
2328
|
+
{{~/if~}}
|
|
2329
|
+
{{/inline}}
|
|
2330
|
+
|
|
2331
|
+
{{~> (lookup . "marker") ~}}
|
|
2332
|
+
`;
|
|
2333
|
+
|
|
2334
|
+
//#endregion
|
|
2335
|
+
//#region src/anki/anki-note-service.ts
|
|
2336
|
+
async function resolveDefaultHandlebars() {
|
|
2337
|
+
try {
|
|
2338
|
+
const module$1 = await import("yomitan-handlebars");
|
|
2339
|
+
return module$1.default ?? module$1;
|
|
2340
|
+
} catch {
|
|
2341
|
+
const module$1 = await import("handlebars");
|
|
2342
|
+
return module$1.default ?? module$1;
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
async function createDefaultAnkiTemplateRenderer(handlebars) {
|
|
2346
|
+
const handlebarsInstance = handlebars ?? await resolveDefaultHandlebars();
|
|
2347
|
+
const renderer = new AnkiTemplateRenderer(handlebarsInstance);
|
|
2348
|
+
await renderer.prepare();
|
|
2349
|
+
return renderer;
|
|
2350
|
+
}
|
|
2351
|
+
function getDefaultAnkiFieldTemplates(dynamicTemplates = "") {
|
|
2352
|
+
const template = DEFAULT_ANKI_FIELD_TEMPLATES.trim();
|
|
2353
|
+
const trimmedDynamicTemplates = dynamicTemplates.trim();
|
|
2354
|
+
if (trimmedDynamicTemplates.length === 0) return template;
|
|
2355
|
+
const markerSnippet = "{{~> (lookup . \"marker\") ~}}";
|
|
2356
|
+
const markerIndex = template.lastIndexOf(markerSnippet);
|
|
2357
|
+
if (markerIndex < 0) return `${template}\n${trimmedDynamicTemplates}`;
|
|
2358
|
+
const before = template.slice(0, markerIndex).trimEnd();
|
|
2359
|
+
const after = template.slice(markerIndex);
|
|
2360
|
+
return `${before}\n\n${trimmedDynamicTemplates}\n\n${after}`;
|
|
2361
|
+
}
|
|
2362
|
+
async function buildAnkiNoteFromDictionaryEntry(input, handlebars) {
|
|
2363
|
+
const renderer = await createDefaultAnkiTemplateRenderer(handlebars);
|
|
2364
|
+
const templateRenderer = renderer.templateRenderer;
|
|
2365
|
+
const builder = new AnkiNoteBuilder({
|
|
2366
|
+
getModifiedData: async (data, type) => templateRenderer.getModifiedData(data, type),
|
|
2367
|
+
renderMulti: async (items) => templateRenderer.renderMulti(items)
|
|
2368
|
+
});
|
|
2369
|
+
return await builder.createNote({
|
|
2370
|
+
dictionaryEntry: input.dictionaryEntry,
|
|
2371
|
+
cardFormat: input.cardFormat,
|
|
2372
|
+
context: input.context,
|
|
2373
|
+
tags: input.tags ?? [],
|
|
2374
|
+
template: input.template ?? getDefaultAnkiFieldTemplates(),
|
|
2375
|
+
duplicateScope: input.duplicateScope ?? "collection",
|
|
2376
|
+
duplicateScopeCheckAllModels: input.duplicateScopeCheckAllModels ?? false,
|
|
2377
|
+
resultOutputMode: input.resultOutputMode ?? "split",
|
|
2378
|
+
glossaryLayoutMode: input.glossaryLayoutMode ?? "default",
|
|
2379
|
+
compactTags: input.compactTags ?? false,
|
|
2380
|
+
dictionaryStylesMap: input.dictionaryStylesMap ?? new Map()
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
//#endregion
|
|
2385
|
+
//#region src/anki/anki-template-util.ts
|
|
2386
|
+
/**
|
|
2387
|
+
* Gets the standard marker names available for a given entry type.
|
|
2388
|
+
*/
|
|
2389
|
+
function getStandardFieldMarkers(type, language = "ja") {
|
|
2390
|
+
switch (type) {
|
|
2391
|
+
case "term": {
|
|
2392
|
+
const markers = [
|
|
2393
|
+
"audio",
|
|
2394
|
+
"clipboard-image",
|
|
2395
|
+
"clipboard-text",
|
|
2396
|
+
"cloze-body",
|
|
2397
|
+
"cloze-prefix",
|
|
2398
|
+
"cloze-suffix",
|
|
2399
|
+
"conjugation",
|
|
2400
|
+
"dictionary",
|
|
2401
|
+
"dictionary-alias",
|
|
2402
|
+
"document-title",
|
|
2403
|
+
"expression",
|
|
2404
|
+
"frequencies",
|
|
2405
|
+
"frequency-harmonic-rank",
|
|
2406
|
+
"frequency-harmonic-occurrence",
|
|
2407
|
+
"frequency-average-rank",
|
|
2408
|
+
"frequency-average-occurrence",
|
|
2409
|
+
"furigana",
|
|
2410
|
+
"furigana-plain",
|
|
2411
|
+
"glossary",
|
|
2412
|
+
"glossary-brief",
|
|
2413
|
+
"glossary-no-dictionary",
|
|
2414
|
+
"glossary-plain",
|
|
2415
|
+
"glossary-plain-no-dictionary",
|
|
2416
|
+
"glossary-first",
|
|
2417
|
+
"glossary-first-brief",
|
|
2418
|
+
"glossary-first-no-dictionary",
|
|
2419
|
+
"part-of-speech",
|
|
2420
|
+
"phonetic-transcriptions",
|
|
2421
|
+
"reading",
|
|
2422
|
+
"screenshot",
|
|
2423
|
+
"search-query",
|
|
2424
|
+
"popup-selection-text",
|
|
2425
|
+
"sentence",
|
|
2426
|
+
"sentence-furigana",
|
|
2427
|
+
"sentence-furigana-plain",
|
|
2428
|
+
"tags",
|
|
2429
|
+
"url"
|
|
2430
|
+
];
|
|
2431
|
+
if (language === "ja") markers.push("cloze-body-kana", "pitch-accents", "pitch-accent-graphs", "pitch-accent-graphs-jj", "pitch-accent-positions", "pitch-accent-categories");
|
|
2432
|
+
return markers;
|
|
2433
|
+
}
|
|
2434
|
+
case "kanji": return [
|
|
2435
|
+
"character",
|
|
2436
|
+
"clipboard-image",
|
|
2437
|
+
"clipboard-text",
|
|
2438
|
+
"cloze-body",
|
|
2439
|
+
"cloze-prefix",
|
|
2440
|
+
"cloze-suffix",
|
|
2441
|
+
"dictionary",
|
|
2442
|
+
"dictionary-alias",
|
|
2443
|
+
"document-title",
|
|
2444
|
+
"frequencies",
|
|
2445
|
+
"frequency-harmonic-rank",
|
|
2446
|
+
"frequency-harmonic-occurrence",
|
|
2447
|
+
"frequency-average-rank",
|
|
2448
|
+
"frequency-average-occurrence",
|
|
2449
|
+
"glossary",
|
|
2450
|
+
"kunyomi",
|
|
2451
|
+
"onyomi",
|
|
2452
|
+
"onyomi-hiragana",
|
|
2453
|
+
"screenshot",
|
|
2454
|
+
"search-query",
|
|
2455
|
+
"popup-selection-text",
|
|
2456
|
+
"sentence",
|
|
2457
|
+
"sentence-furigana",
|
|
2458
|
+
"sentence-furigana-plain",
|
|
2459
|
+
"stroke-count",
|
|
2460
|
+
"tags",
|
|
2461
|
+
"url"
|
|
2462
|
+
];
|
|
2463
|
+
default: return [];
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Returns dynamic marker names derived from enabled dictionaries.
|
|
2468
|
+
*/
|
|
2469
|
+
function getDynamicFieldMarkers(dictionaries, dictionaryInfo) {
|
|
2470
|
+
const markers = [];
|
|
2471
|
+
for (const dictionary of dictionaries) {
|
|
2472
|
+
const currentDictionaryInfo = dictionaryInfo.find(({ title }) => title === dictionary.name);
|
|
2473
|
+
if (!dictionary.enabled) continue;
|
|
2474
|
+
const totalTerms = currentDictionaryInfo?.counts?.terms?.total;
|
|
2475
|
+
if (totalTerms && totalTerms > 0) markers.push(`single-glossary-${getKebabCase(dictionary.name)}`);
|
|
2476
|
+
const totalMeta = currentDictionaryInfo?.counts?.termMeta;
|
|
2477
|
+
if (totalMeta && totalMeta.freq && totalMeta.freq > 0) markers.push(`single-frequency-number-${getKebabCase(dictionary.name)}`);
|
|
2478
|
+
}
|
|
2479
|
+
return markers;
|
|
2480
|
+
}
|
|
2481
|
+
/**
|
|
2482
|
+
* Returns dynamic inline template partials derived from enabled dictionaries.
|
|
2483
|
+
*/
|
|
2484
|
+
function getDynamicTemplates(dictionaries, dictionaryInfo) {
|
|
2485
|
+
let dynamicTemplates = "\n";
|
|
2486
|
+
for (const dictionary of dictionaries) {
|
|
2487
|
+
const currentDictionaryInfo = dictionaryInfo.find(({ title }) => title === dictionary.name);
|
|
2488
|
+
if (!dictionary.enabled) continue;
|
|
2489
|
+
const totalTerms = currentDictionaryInfo?.counts?.terms?.total;
|
|
2490
|
+
if (totalTerms && totalTerms > 0) dynamicTemplates += `
|
|
2491
|
+
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}"}}
|
|
2492
|
+
{{~> glossary selectedDictionary='${escapeDictName(dictionary.name)}'}}
|
|
2493
|
+
{{/inline}}
|
|
2494
|
+
|
|
2495
|
+
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}-no-dictionary"}}
|
|
2496
|
+
{{~> glossary selectedDictionary='${escapeDictName(dictionary.name)}' noDictionaryTag=true}}
|
|
2497
|
+
{{/inline}}
|
|
2498
|
+
|
|
2499
|
+
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}-brief"}}
|
|
2500
|
+
{{~> glossary selectedDictionary='${escapeDictName(dictionary.name)}' brief=true}}
|
|
2501
|
+
{{/inline}}
|
|
2502
|
+
|
|
2503
|
+
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}-plain"}}
|
|
2504
|
+
{{~> glossary-plain selectedDictionary='${escapeDictName(dictionary.name)}'}}
|
|
2505
|
+
{{/inline}}
|
|
2506
|
+
|
|
2507
|
+
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}-plain-no-dictionary"}}
|
|
2508
|
+
{{~> glossary-plain-no-dictionary selectedDictionary='${escapeDictName(dictionary.name)}' noDictionaryTag=true}}
|
|
2509
|
+
{{/inline}}
|
|
2510
|
+
`;
|
|
2511
|
+
const totalMeta = currentDictionaryInfo?.counts?.termMeta;
|
|
2512
|
+
if (totalMeta && totalMeta.freq && totalMeta.freq > 0) dynamicTemplates += `
|
|
2513
|
+
{{#*inline "single-frequency-number-${getKebabCase(dictionary.name)}"}}
|
|
2514
|
+
{{~> single-frequency-number selectedDictionary='${escapeDictName(dictionary.name)}'}}
|
|
2515
|
+
{{/inline}}
|
|
2516
|
+
{{#*inline "single-frequency-${getKebabCase(dictionary.name)}"}}
|
|
2517
|
+
{{~> frequencies selectedDictionary='${escapeDictName(dictionary.name)}'}}
|
|
2518
|
+
{{/inline}}
|
|
2519
|
+
`;
|
|
2520
|
+
}
|
|
2521
|
+
return dynamicTemplates;
|
|
2522
|
+
}
|
|
2523
|
+
function getKebabCase(str) {
|
|
2524
|
+
return str.replace(/[\s_\u3000]/g, "-").replace(/[^\p{L}\p{N}-]/gu, "").replace(/--+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
2525
|
+
}
|
|
2526
|
+
function escapeDictName(name) {
|
|
2527
|
+
return name.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
2528
|
+
}
|
|
2529
|
+
|
|
1751
2530
|
//#endregion
|
|
1752
2531
|
exports.AnkiConnect = require_anki_connect.AnkiConnect
|
|
1753
2532
|
exports.AnkiNoteBuilder = AnkiNoteBuilder
|
|
1754
2533
|
exports.AnkiTemplateRenderer = AnkiTemplateRenderer
|
|
2534
|
+
exports.DEFAULT_ANKI_FIELD_TEMPLATES = DEFAULT_ANKI_FIELD_TEMPLATES
|
|
2535
|
+
exports.buildAnkiNoteFromDictionaryEntry = buildAnkiNoteFromDictionaryEntry
|
|
1755
2536
|
exports.createAnkiNoteData = createAnkiNoteData
|
|
1756
2537
|
exports.createCachedValue = createCachedValue
|
|
2538
|
+
exports.createDefaultAnkiTemplateRenderer = createDefaultAnkiTemplateRenderer
|
|
1757
2539
|
exports.getCachedValue = getCachedValue
|
|
2540
|
+
exports.getDefaultAnkiFieldTemplates = getDefaultAnkiFieldTemplates
|
|
2541
|
+
exports.getDynamicFieldMarkers = getDynamicFieldMarkers
|
|
2542
|
+
exports.getDynamicTemplates = getDynamicTemplates
|
|
1758
2543
|
exports.getFrequencyHarmonic = getFrequencyHarmonic
|
|
2544
|
+
exports.getKebabCase = getKebabCase
|
|
2545
|
+
exports.getStandardFieldMarkers = getStandardFieldMarkers
|
|
1759
2546
|
//# sourceMappingURL=anki.cjs.map
|