fixing cloze bug
This commit is contained in:
parent
c4b1a4a5b4
commit
1ba458ea82
@ -368,9 +368,6 @@ function ankiFieldsPopulate(element, options) {
|
||||
],
|
||||
'kanji': [
|
||||
'character',
|
||||
'cloze-body',
|
||||
'cloze-prefix',
|
||||
'cloze-suffix',
|
||||
'dictionary',
|
||||
'glossary',
|
||||
'kunyomi',
|
||||
|
@ -182,7 +182,7 @@ function docSentenceExtract(source, extent) {
|
||||
|
||||
quoteStack = [];
|
||||
|
||||
let endPos = content.length - 1;
|
||||
let endPos = content.length;
|
||||
for (let i = position; i <= endPos; ++i) {
|
||||
const c = content[i];
|
||||
|
||||
@ -205,7 +205,7 @@ function docSentenceExtract(source, extent) {
|
||||
}
|
||||
|
||||
const text = content.substring(startPos, endPos);
|
||||
const padding = text.length - text.replace(/^\s+/, '');
|
||||
const padding = text.length - text.replace(/^\s+/, '').length;
|
||||
|
||||
return {
|
||||
text: text.trim(),
|
||||
|
@ -108,7 +108,7 @@ class Display {
|
||||
|
||||
if (context) {
|
||||
for (const definition of definitions) {
|
||||
definition.cloze = clozeBuild(context.sentence, definition.source);
|
||||
definition.cloze = clozeBuild(context.sentence);
|
||||
definition.url = context.url;
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,17 @@
|
||||
*/
|
||||
|
||||
function clozeBuild(sentence, source) {
|
||||
return {
|
||||
sentence: sentence.text.trim(),
|
||||
prefix: sentence.text.substring(0, sentence.offset).trim(),
|
||||
body: source.trim(),
|
||||
suffix: sentence.text.substring(sentence.offset + source.length).trim()
|
||||
const result = {
|
||||
sentence: sentence.text.trim()
|
||||
};
|
||||
|
||||
if (source) {
|
||||
result.prefix = sentence.text.substring(0, sentence.offset).trim();
|
||||
result.body = source.trim();
|
||||
result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user