diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/data/templates/anki-field-templates-upgrade-v35.handlebars | 33 | ||||
-rw-r--r-- | ext/data/templates/default-anki-field-templates.handlebars | 24 | ||||
-rw-r--r-- | ext/js/data/anki-template-util.js | 3 | ||||
-rw-r--r-- | ext/js/data/options-util.js | 11 | ||||
-rw-r--r-- | ext/settings.html | 12 |
5 files changed, 82 insertions, 1 deletions
diff --git a/ext/data/templates/anki-field-templates-upgrade-v35.handlebars b/ext/data/templates/anki-field-templates-upgrade-v35.handlebars new file mode 100644 index 00000000..e71efcf8 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v35.handlebars @@ -0,0 +1,33 @@ +{{<<<<<<<}} +{{#*inline "glossary-brief"}} + {{~> glossary brief=true ~}} +{{/inline}} +{{=======}} +{{#*inline "glossary-brief"}} + {{~> glossary brief=true ~}} +{{/inline}} + +{{~#*inline "glossary-first"~}} + <div style="text-align: left;"> + {{~#scope~}} + {{~#if (op "===" definition.type "term")~}} + {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} + {{~#if (op ">" definition.definitions.length 1)~}} + {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}} + {{~else~}} + {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}} + {{~/if~}} + {{~/if~}} + {{~/scope~}} + </div> +{{~/inline~}} + +{{#*inline "glossary-first-no-dictionary"}} + {{~> glossary-first noDictionaryTag=true ~}} +{{/inline}} + +{{#*inline "glossary-first-brief"}} + {{~> glossary-first brief=true ~}} +{{/inline}} +{{>>>>>>>}}
\ No newline at end of file diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 3f20f8ee..53dab1c1 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -141,6 +141,30 @@ {{~> glossary brief=true ~}} {{/inline}} +{{~#*inline "glossary-first"~}} + <div style="text-align: left;"> + {{~#scope~}} + {{~#if (op "===" definition.type "term")~}} + {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}} + {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}} + {{~#if (op ">" definition.definitions.length 1)~}} + {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}} + {{~else~}} + {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}} + {{~/if~}} + {{~/if~}} + {{~/scope~}} + </div> +{{~/inline~}} + +{{#*inline "glossary-first-no-dictionary"}} + {{~> glossary-first noDictionaryTag=true ~}} +{{/inline}} + +{{#*inline "glossary-first-brief"}} + {{~> glossary-first brief=true ~}} +{{/inline}} + {{#*inline "kunyomi"}} {{~#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}} {{/inline}} diff --git a/ext/js/data/anki-template-util.js b/ext/js/data/anki-template-util.js index b9c5ba84..20170dae 100644 --- a/ext/js/data/anki-template-util.js +++ b/ext/js/data/anki-template-util.js @@ -46,6 +46,9 @@ export function getStandardFieldMarkers(type) { 'glossary', 'glossary-brief', 'glossary-no-dictionary', + 'glossary-first', + 'glossary-first-brief', + 'glossary-first-no-dictionary', 'part-of-speech', 'pitch-accents', 'pitch-accent-graphs', diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index ba404bc2..521b4c9b 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -541,7 +541,8 @@ export class OptionsUtil { this._updateVersion31, this._updateVersion32, this._updateVersion33, - this._updateVersion34 + this._updateVersion34, + this._updateVersion35 ]; /* eslint-enable @typescript-eslint/unbound-method */ if (typeof targetVersion === 'number' && targetVersion < result.length) { @@ -1277,6 +1278,14 @@ export class OptionsUtil { await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v34.handlebars'); } + /** + * - Added dynamic handlebars for first dictionary entry only. + * @type {import('options-util').UpdateFunction} + */ + async _updateVersion35(options) { + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v35.handlebars'); + } + /** * @param {string} url diff --git a/ext/settings.html b/ext/settings.html index 252de038..8dfd6f51 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -2984,6 +2984,18 @@ <td>List of definitions for the term, except the dictionary tag is omitted.</td> </tr> <tr> + <td><code class="anki-field-marker">{glossary}</code></td> + <td>First definition for the term.</td> + </tr> + <tr> + <td><code class="anki-field-marker">{glossary-brief}</code></td> + <td>First definition for the term in a more compact format.</td> + </tr> + <tr> + <td><code class="anki-field-marker">{glossary-no-dictionary}</code></td> + <td>First definition for the term, except the dictionary tag is omitted.</td> + </tr> + <tr> <td><code class="anki-field-marker">{part-of-speech}</code></td> <td>Part of speech information for the term.</td> </tr> |