diff --git a/README.md b/README.md index 922176bb..843ccf98 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Flashcard fields can be configured with the following steps: `{pitch-accent-positions}` | List of accent downstep positions for the term as a number. `{reading}` | Kana reading for the term (empty for terms where the expression is the reading). `{screenshot}` | Screenshot of the web page taken at the time the term was added. + `{search-query}` | The full search query shown on the search page. `{sentence}` | Sentence, quote, or phrase that the term appears in from the source content. `{tags}` | Grammar and usage tags providing information about the term (unavailable in *grouped* mode). `{url}` | Address of the web page in which the term appeared in. @@ -197,6 +198,7 @@ Flashcard fields can be configured with the following steps: `{kunyomi}` | Kunyomi (Japanese reading) for the kanji expressed as katakana. `{onyomi}` | Onyomi (Chinese reading) for the kanji expressed as hiragana. `{screenshot}` | Screenshot of the web page taken at the time the kanji was added. + `{search-query}` | The full search query shown on the search page. `{sentence}` | Sentence, quote, or phrase that the character appears in from the source content. `{stroke-count}` | Number of strokes that the kanji character has. `{url}` | Address of the web page in which the kanji appeared in. diff --git a/dev/translator-vm.js b/dev/translator-vm.js index 4b5403da..8397b65e 100644 --- a/dev/translator-vm.js +++ b/dev/translator-vm.js @@ -116,7 +116,9 @@ class TranslatorVM extends DatabaseVM { context: { url: 'url:', sentence: {text: '', offset: 0}, - documentTitle: 'title' + documentTitle: 'title', + query: 'query', + fullQuery: 'fullQuery' }, injectedMedia: null }; diff --git a/ext/data/templates/anki-field-templates-upgrade-v12.handlebars b/ext/data/templates/anki-field-templates-upgrade-v12.handlebars new file mode 100644 index 00000000..9fe3c9d0 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v12.handlebars @@ -0,0 +1,3 @@ +{{#*inline "search-query"}} + {{~#multiLine}}{{context.fullQuery}}{{/multiLine~}} +{{/inline}} diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index ec57a826..97359aa0 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -372,4 +372,8 @@ {{~/scope~}} {{/inline}} +{{#*inline "search-query"}} + {{~#multiLine}}{{context.fullQuery}}{{/multiLine~}} +{{/inline}} + {{~> (lookup . "marker") ~}} diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js index d1bbec18..4cf62788 100644 --- a/ext/js/data/anki-note-data-creator.js +++ b/ext/js/data/anki-note-data-creator.js @@ -141,9 +141,11 @@ class AnkiNoteDataCreator { } _getPublicContext(context) { - let {documentTitle} = this._asObject(context); + let {documentTitle, query, fullQuery} = this._asObject(context); if (typeof documentTitle !== 'string') { documentTitle = ''; } return { + query, + fullQuery, document: { title: documentTitle } diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index cb58206f..00ad890d 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -461,7 +461,7 @@ class OptionsUtil { {async: false, update: this._updateVersion9.bind(this)}, {async: true, update: this._updateVersion10.bind(this)}, {async: false, update: this._updateVersion11.bind(this)}, - {async: false, update: this._updateVersion12.bind(this)} + {async: true, update: this._updateVersion12.bind(this)} ]; } @@ -813,9 +813,11 @@ class OptionsUtil { return options; } - _updateVersion12(options) { + async _updateVersion12(options) { // Version 12 changes: // Changed sentenceParsing.enableTerminationCharacters to sentenceParsing.terminationCharacterMode. + // Added {search-query} field marker. + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v12.handlebars'); for (const profile of options.profiles) { const {sentenceParsing} = profile.options; sentenceParsing.terminationCharacterMode = sentenceParsing.enableTerminationCharacters ? 'custom' : 'newlines'; diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 7bfe3add..fe5b5c9a 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1400,7 +1400,9 @@ class Display extends EventDispatcher { return { url, sentence, - documentTitle + documentTitle, + query: this._query, + fullQuery: this._fullQuery }; } diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 91cd4641..28bb21a3 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -101,6 +101,7 @@ class AnkiController { 'pitch-accent-positions', 'reading', 'screenshot', + 'search-query', 'sentence', 'tags', 'url' @@ -119,6 +120,7 @@ class AnkiController { 'kunyomi', 'onyomi', 'screenshot', + 'search-query', 'sentence', 'stroke-count', 'tags', diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index eab0681f..9502a2fd 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -161,7 +161,9 @@ class AnkiTemplatesController { text: sentenceText, offset: 0 }, - documentTitle: document.title + documentTitle: document.title, + query: sentenceText, + fullQuery: sentenceText }; let template = options.anki.fieldTemplates; if (typeof template !== 'string') { template = this._defaultFieldTemplates; } diff --git a/ext/settings.html b/ext/settings.html index 1b167e22..aade3345 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -2877,6 +2877,10 @@ {screenshot} Screenshot of the web page taken at the time the term or kanji was added. + + {search-query} + The full search query shown on the search page. + {sentence} Sentence, quote, or phrase that the term or kanji appears in from the source content. diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index bcf3eb6d..851584c8 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -15,6 +15,7 @@ "kunyomi": "う.つ, う.ち-, ぶ.つ", "onyomi": "ダ, ダアス", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", @@ -38,6 +39,7 @@ "kunyomi": "-こ.む, こ.む, こ.み, -こ.み, こ.める", "onyomi": "", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix込cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", @@ -75,6 +77,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -102,6 +105,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -134,6 +138,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打つcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -161,6 +166,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打つcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -188,6 +194,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打つcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -215,6 +222,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打つcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -242,6 +250,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -269,6 +278,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -301,6 +311,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -328,6 +339,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -355,6 +367,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -382,6 +395,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -409,6 +423,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -436,6 +451,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -463,6 +479,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -490,6 +507,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -517,6 +535,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -544,6 +563,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -576,6 +596,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "がぞう", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix画像cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -608,6 +629,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixだcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -640,6 +662,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixダースcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -672,6 +695,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうつcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -699,6 +723,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうつcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -731,6 +756,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶつcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -758,6 +784,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶつcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -790,6 +817,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -817,6 +845,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -844,6 +873,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -871,6 +901,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -903,6 +934,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶちこむcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -930,6 +962,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶちこむcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -957,6 +990,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -984,6 +1018,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixぶちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1016,6 +1051,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "がぞう", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixがぞうcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1060,6 +1096,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1087,6 +1124,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1114,6 +1152,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1141,6 +1180,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1168,6 +1208,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1195,6 +1236,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1227,6 +1269,7 @@ "pitch-accent-positions": "
  1. (うちこむ only) [0]
  2. (うちこむ only) [3]
  3. (ぶちこむ only) [0]
  4. (ぶちこむ only) [3]
", "reading": "うちこむ、ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1254,6 +1297,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ、ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1281,6 +1325,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1308,6 +1353,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1340,6 +1386,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1367,6 +1414,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1394,6 +1442,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1421,6 +1470,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1448,6 +1498,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1475,6 +1526,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1502,6 +1554,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1529,6 +1582,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1556,6 +1610,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1583,6 +1638,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1615,6 +1671,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1642,6 +1699,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1669,6 +1727,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1696,6 +1755,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1723,6 +1783,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1750,6 +1811,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1777,6 +1839,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1804,6 +1867,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1831,6 +1895,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1858,6 +1923,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix打cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1890,6 +1956,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1917,6 +1984,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1944,6 +2012,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "うちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1971,6 +2040,7 @@ "pitch-accent-positions": "
  1. [0]
  2. [3]
", "reading": "ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -1998,6 +2068,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2025,6 +2096,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2052,6 +2124,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2079,6 +2152,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2106,6 +2180,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "だ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2133,6 +2208,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "ダース", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefix(打)cloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2165,6 +2241,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "よむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixtestcloze-suffix", "tags": "popular", "url": "url:" @@ -2197,6 +2274,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "つよみ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixつtestcloze-suffix", "tags": "popular", "url": "url:" @@ -2229,6 +2307,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "よむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixtestましたcloze-suffix", "tags": "popular", "url": "url:" @@ -2261,6 +2340,7 @@ "pitch-accent-positions": "
  1. (うちこむ only) [0]
  2. (うちこむ only) [3]
  3. (ぶちこむ only) [0]
  4. (ぶちこむ only) [3]
", "reading": "うちこむ、ぶちこむ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "tag1, tag2", "url": "url:" @@ -2288,6 +2368,7 @@ "pitch-accent-positions": "No pitch accent data", "reading": "うつ、ぶつ", "screenshot": "", + "search-query": "fullQuery", "sentence": "cloze-prefixうちcloze-suffix", "tags": "tag1, tag2", "url": "url:" diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index e9d41526..740e6661 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -138,6 +138,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -283,6 +285,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -510,6 +514,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -728,6 +734,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -961,6 +969,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -1189,6 +1199,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -1417,6 +1429,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -1645,6 +1659,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -1863,6 +1879,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -2081,6 +2099,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -2400,6 +2420,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -2714,6 +2736,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -3028,6 +3052,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -3342,6 +3368,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -3572,6 +3600,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -3802,6 +3832,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -4032,6 +4064,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -4262,6 +4296,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -4480,6 +4516,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -4698,6 +4736,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -4876,6 +4916,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -5099,6 +5141,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -5322,6 +5366,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -5555,6 +5601,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -5783,6 +5831,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -6016,6 +6066,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -6244,6 +6296,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -6563,6 +6617,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -6877,6 +6933,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -7107,6 +7165,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -7337,6 +7397,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -7656,6 +7718,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -7970,6 +8034,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -8200,6 +8266,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -8430,6 +8498,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -8608,6 +8678,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -8989,6 +9061,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -9317,6 +9391,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -9569,6 +9645,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -9821,6 +9899,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -10037,6 +10117,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -10253,6 +10335,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -10830,6 +10914,8 @@ ], "pitchCount": 4, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -11229,6 +11315,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -11420,6 +11508,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -11611,6 +11701,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -11934,6 +12026,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -12252,6 +12346,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -12570,6 +12666,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -12888,6 +12986,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -13118,6 +13218,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -13348,6 +13450,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -13578,6 +13682,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -13808,6 +13914,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -14026,6 +14134,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -14244,6 +14354,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -14563,6 +14675,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -14877,6 +14991,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -15191,6 +15307,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -15505,6 +15623,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -15735,6 +15855,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -15965,6 +16087,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -16195,6 +16319,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -16425,6 +16551,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -16643,6 +16771,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -16861,6 +16991,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -17180,6 +17312,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -17494,6 +17628,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -17808,6 +17944,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -18122,6 +18260,8 @@ ], "pitchCount": 2, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -18352,6 +18492,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -18582,6 +18724,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -18812,6 +18956,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19042,6 +19188,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19260,6 +19408,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19478,6 +19628,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19613,6 +19765,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19726,6 +19880,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -19861,6 +20017,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -20438,6 +20596,8 @@ ], "pitchCount": 4, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } @@ -20837,6 +20997,8 @@ "pitches": [], "pitchCount": 0, "context": { + "query": "query", + "fullQuery": "fullQuery", "document": { "title": "title" } diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js index d8fd558e..2ab79551 100644 --- a/test/test-anki-note-builder.js +++ b/test/test-anki-note-builder.js @@ -110,6 +110,7 @@ function getFieldMarkers(type) { 'pitch-accent-positions', 'reading', 'screenshot', + 'search-query', 'sentence', 'tags', 'url' @@ -128,6 +129,7 @@ function getFieldMarkers(type) { 'kunyomi', 'onyomi', 'screenshot', + 'search-query', 'sentence', 'stroke-count', 'tags', @@ -167,7 +169,9 @@ async function getRenderResults(dictionaryEntries, type, mode, template, AnkiNot text: `${clozePrefix}${source}${clozeSuffix}`, offset: clozePrefix.length }, - documentTitle: 'title' + documentTitle: 'title', + query: 'query', + fullQuery: 'fullQuery' }; const errors = []; const noteFields = (await ankiNoteBuilder.createNote({ diff --git a/test/test-options-util.js b/test/test-options-util.js index 8b65f134..7e11aad1 100644 --- a/test/test-options-util.js +++ b/test/test-options-util.js @@ -641,6 +641,7 @@ async function testFieldTemplatesUpdate(extDir) { const update6 = loadDataFile('data/templates/anki-field-templates-upgrade-v6.handlebars'); const update8 = loadDataFile('data/templates/anki-field-templates-upgrade-v8.handlebars'); const update10 = loadDataFile('data/templates/anki-field-templates-upgrade-v10.handlebars'); + const update12 = loadDataFile('data/templates/anki-field-templates-upgrade-v12.handlebars'); const data = [ // Standard format @@ -662,6 +663,7 @@ ${update4} ${update6} ${update8} ${update10} +${update12} {{~> (lookup . "marker") ~}}`.trimStart() }, // Non-standard marker format @@ -683,7 +685,8 @@ ${update2} ${update4} ${update6} ${update8} -${update10}`.trimStart() +${update10} +${update12}`.trimStart() }, // Empty test { @@ -696,6 +699,7 @@ ${update4} ${update6} ${update8} ${update10} +${update12} {{~> (lookup . "marker") ~}}`.trimStart() }, // Definition tags update @@ -770,6 +774,7 @@ ${update4} ${update6} ${update8} ${update10} +${update12} {{~> (lookup . "marker") ~}} `.trimStart() }, @@ -911,6 +916,7 @@ ${update10} ${update8} ${update10} +${update12} {{~> (lookup . "marker") ~}}`.trimStart() } ];