summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--ext/bg/data/anki-field-templates-upgrade-v6.handlebars8
-rw-r--r--ext/bg/data/default-anki-field-templates.handlebars9
-rw-r--r--ext/bg/js/options.js11
-rw-r--r--ext/bg/js/settings/anki-controller.js1
-rw-r--r--test/test-options-util.js8
6 files changed, 36 insertions, 2 deletions
diff --git a/README.md b/README.md
index 8be40026..fd8e23a3 100644
--- a/README.md
+++ b/README.md
@@ -159,6 +159,7 @@ Flashcard fields can be configured with the following steps:
`{cloze-body}` | Raw, inflected term as it appeared before being reduced to dictionary form by Yomichan.
`{cloze-prefix}` | Fragment of the containing `{sentence}` starting at the beginning of `{sentence}` until the beginning of `{cloze-body}`.
`{cloze-suffix}` | Fragment of the containing `{sentence}` starting at the end of `{cloze-body}` until the end of `{sentence}`.
+ `{conjugation}` | Conjugation path from the raw inflected term to the source term.
`{dictionary}` | Name of the dictionary from which the card is being created (unavailable in *grouped* mode).
`{document-title}` | Title of the web page that the term appeared in.
`{expression}` | Term expressed as kanji (will be displayed in kana if kanji is not available).
diff --git a/ext/bg/data/anki-field-templates-upgrade-v6.handlebars b/ext/bg/data/anki-field-templates-upgrade-v6.handlebars
new file mode 100644
index 00000000..33a2f949
--- /dev/null
+++ b/ext/bg/data/anki-field-templates-upgrade-v6.handlebars
@@ -0,0 +1,8 @@
+{{#*inline "conjugation"}}
+ {{~#if definition.reasons~}}
+ {{~#each definition.reasons~}}
+ {{~#if (op ">" @index 0)}} « {{/if~}}
+ {{.}}
+ {{~/each~}}
+ {{~/if~}}
+{{/inline}}
diff --git a/ext/bg/data/default-anki-field-templates.handlebars b/ext/bg/data/default-anki-field-templates.handlebars
index 2849ade9..776792c7 100644
--- a/ext/bg/data/default-anki-field-templates.handlebars
+++ b/ext/bg/data/default-anki-field-templates.handlebars
@@ -286,4 +286,13 @@
{{~#if definition.clipboardText~}}{{definition.clipboardText}}{{~/if~}}
{{/inline}}
+{{#*inline "conjugation"}}
+ {{~#if definition.reasons~}}
+ {{~#each definition.reasons~}}
+ {{~#if (op ">" @index 0)}} « {{/if~}}
+ {{.}}
+ {{~/each~}}
+ {{~/if~}}
+{{/inline}}
+
{{~> (lookup . "marker") ~}}
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 668be98e..00d4725a 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -477,6 +477,10 @@ class OptionsUtil {
{
async: false,
update: this._updateVersion5.bind(this)
+ },
+ {
+ async: true,
+ update: this._updateVersion6.bind(this)
}
];
}
@@ -604,4 +608,11 @@ class OptionsUtil {
}
return options;
}
+
+ async _updateVersion6(options) {
+ // Version 6 changes:
+ // Updated handlebars templates to include "conjugation" definition.
+ await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v6.handlebars');
+ return options;
+ }
}
diff --git a/ext/bg/js/settings/anki-controller.js b/ext/bg/js/settings/anki-controller.js
index c205c160..d9b1591e 100644
--- a/ext/bg/js/settings/anki-controller.js
+++ b/ext/bg/js/settings/anki-controller.js
@@ -79,6 +79,7 @@ class AnkiController {
'cloze-body',
'cloze-prefix',
'cloze-suffix',
+ 'conjugation',
'dictionary',
'document-title',
'expression',
diff --git a/test/test-options-util.js b/test/test-options-util.js
index 00786dd6..c3ff4c8f 100644
--- a/test/test-options-util.js
+++ b/test/test-options-util.js
@@ -496,7 +496,7 @@ function createOptionsUpdatedTestData1() {
}
],
profileCurrent: 0,
- version: 5,
+ version: 6,
global: {
database: {
prefixWildcardsSupported: false
@@ -554,6 +554,7 @@ async function testFieldTemplatesUpdate(extDir) {
const loadDataFile = (fileName) => fs.readFileSync(path.join(extDir, fileName), {encoding: 'utf8'});
const update2 = loadDataFile('bg/data/anki-field-templates-upgrade-v2.handlebars');
const update4 = loadDataFile('bg/data/anki-field-templates-upgrade-v4.handlebars');
+ const update6 = loadDataFile('bg/data/anki-field-templates-upgrade-v6.handlebars');
const data = [
// Standard format
@@ -572,6 +573,7 @@ async function testFieldTemplatesUpdate(extDir) {
${update2}
${update4}
+${update6}
{{~> (lookup . "marker") ~}}`.trimStart()
},
// Non-standard marker format
@@ -590,7 +592,8 @@ ${update4}
{{~> (lookup . "marker2") ~}}
${update2}
-${update4}`.trimStart()
+${update4}
+${update6}`.trimStart()
},
// Empty test
{
@@ -600,6 +603,7 @@ ${update4}`.trimStart()
expected: `
${update2}
${update4}
+${update6}
{{~> (lookup . "marker") ~}}`.trimStart()
}
];