Add support for {document-title}
This commit is contained in:
parent
059db280bb
commit
4011a091b6
@ -156,6 +156,7 @@ Flashcard fields can be configured with the following steps:
|
|||||||
`{cloze-prefix}` | Text for the containing `{sentence}` from the start up to the value of `{cloze-body}`.
|
`{cloze-prefix}` | Text for the containing `{sentence}` from the start up to the value of `{cloze-body}`.
|
||||||
`{cloze-suffix}` | Text for the containing `{sentence}` from the value of `{cloze-body}` to the end.
|
`{cloze-suffix}` | Text for the containing `{sentence}` from the value of `{cloze-body}` to the end.
|
||||||
`{dictionary}` | Name of the dictionary from which the card is being created (unavailable in *grouped* mode).
|
`{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).
|
`{expression}` | Term expressed as Kanji (will be displayed in Kana if Kanji is not available).
|
||||||
`{furigana}` | Term expressed as Kanji with Furigana displayed above it (e.g. <ruby>日本語<rt>にほんご</rt></ruby>).
|
`{furigana}` | Term expressed as Kanji with Furigana displayed above it (e.g. <ruby>日本語<rt>にほんご</rt></ruby>).
|
||||||
`{furigana-plain}` | Term expressed as Kanji with Furigana displayed next to it in brackets (e.g. 日本語[にほんご]).
|
`{furigana-plain}` | Term expressed as Kanji with Furigana displayed next to it in brackets (e.g. 日本語[にほんご]).
|
||||||
@ -175,6 +176,7 @@ Flashcard fields can be configured with the following steps:
|
|||||||
`{cloze-prefix}` | Text for the containing `{sentence}` from the start up to the value of `{cloze-body}`.
|
`{cloze-prefix}` | Text for the containing `{sentence}` from the start up to the value of `{cloze-body}`.
|
||||||
`{cloze-suffix}` | Text for the containing `{sentence}` from the value of `{cloze-body}` to the end.
|
`{cloze-suffix}` | Text for the containing `{sentence}` from the value of `{cloze-body}` to the end.
|
||||||
`{dictionary}` | Name of the dictionary from which the card is being created.
|
`{dictionary}` | Name of the dictionary from which the card is being created.
|
||||||
|
`{document-title}` | Title of the web page that the Kanji appeared in.
|
||||||
`{glossary}` | List of definitions for the Kanji.
|
`{glossary}` | List of definitions for the Kanji.
|
||||||
`{kunyomi}` | Kunyomi (Japanese reading) for the Kanji expressed as Katakana.
|
`{kunyomi}` | Kunyomi (Japanese reading) for the Kanji expressed as Katakana.
|
||||||
`{onyomi}` | Onyomi (Chinese reading) for the Kanji expressed as Hiragana.
|
`{onyomi}` | Onyomi (Chinese reading) for the Kanji expressed as Hiragana.
|
||||||
|
@ -158,4 +158,8 @@
|
|||||||
<img src="{{definition.screenshotFileName}}" />
|
<img src="{{definition.screenshotFileName}}" />
|
||||||
{{/inline}}
|
{{/inline}}
|
||||||
|
|
||||||
|
{{#*inline "document-title"}}
|
||||||
|
{{~context.document.title~}}
|
||||||
|
{{/inline}}
|
||||||
|
|
||||||
{{~> (lookup . "marker") ~}}
|
{{~> (lookup . "marker") ~}}
|
@ -91,6 +91,15 @@ const profileOptionsVersionUpdates = [
|
|||||||
if (utilStringHashCode(options.anki.fieldTemplates) === 1444379824) {
|
if (utilStringHashCode(options.anki.fieldTemplates) === 1444379824) {
|
||||||
options.anki.fieldTemplates = null;
|
options.anki.fieldTemplates = null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
(options) => {
|
||||||
|
// Version 13 changes:
|
||||||
|
// Default anki field tempaltes updated to include {document-title}.
|
||||||
|
let fieldTemplates = options.anki.fieldTemplates;
|
||||||
|
if (typeof fieldTemplates === 'string') {
|
||||||
|
fieldTemplates += '\n\n{{#*inline "document-title"}}\n {{~context.document.title~}}\n{{/inline}}';
|
||||||
|
options.anki.fieldTemplates = fieldTemplates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -99,7 +99,11 @@ async function ankiTemplatesValidate(infoNode, field, mode, showSuccessResult, i
|
|||||||
const definition = await ankiTemplatesValidateGetDefinition(text, optionsContext);
|
const definition = await ankiTemplatesValidateGetDefinition(text, optionsContext);
|
||||||
if (definition !== null) {
|
if (definition !== null) {
|
||||||
const options = await apiOptionsGet(optionsContext);
|
const options = await apiOptionsGet(optionsContext);
|
||||||
const context = {};
|
const context = {
|
||||||
|
document: {
|
||||||
|
title: document.title
|
||||||
|
}
|
||||||
|
};
|
||||||
let templates = options.anki.fieldTemplates;
|
let templates = options.anki.fieldTemplates;
|
||||||
if (typeof templates !== 'string') { templates = await apiGetDefaultAnkiFieldTemplates(); }
|
if (typeof templates !== 'string') { templates = await apiGetDefaultAnkiFieldTemplates(); }
|
||||||
const ankiNoteBuilder = new AnkiNoteBuilder({renderTemplate: apiTemplateRender});
|
const ankiNoteBuilder = new AnkiNoteBuilder({renderTemplate: apiTemplateRender});
|
||||||
|
@ -935,7 +935,11 @@ class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getNoteContext() {
|
_getNoteContext() {
|
||||||
return {};
|
return {
|
||||||
|
document: {
|
||||||
|
title: document.title
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _getAudioUri(definition, source) {
|
async _getAudioUri(definition, source) {
|
||||||
|
Loading…
Reference in New Issue
Block a user