wip
This commit is contained in:
parent
e6b592b4c0
commit
bbe4afecf6
@ -205,14 +205,10 @@ function docClozeExtract(source, extent) {
|
||||
}
|
||||
|
||||
const sentence = content.substring(startPos, endPos);
|
||||
const clozePrefix = sentence.substring(0, position - startPos);
|
||||
const clozeBody = source.text();
|
||||
const clozeSuffix = sentence.substring(position - startPos + clozeBody.length);
|
||||
const padding = sentence.length - sentence.replace(/^\s+/, '');
|
||||
|
||||
return {
|
||||
sentence: sentence.trim(),
|
||||
prefix: clozePrefix.trim(),
|
||||
body: clozeBody.trim(),
|
||||
suffix: clozeSuffix.trim()
|
||||
offset: position - startPos - padding
|
||||
};
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class Display {
|
||||
|
||||
if (context) {
|
||||
for (const definition of definitions) {
|
||||
definition.cloze = context.cloze;
|
||||
definition.cloze = clozeBuild(context.cloze);
|
||||
definition.url = context.url;
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,7 @@ class Display {
|
||||
|
||||
if (context) {
|
||||
for (const definition of definitions) {
|
||||
definition.cloze = context.cloze;
|
||||
definition.cloze = clozeBuild(context.cloze);
|
||||
definition.url = context.url;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,20 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Cloze
|
||||
*/
|
||||
|
||||
function clozeBuild(sentence, offset, source) {
|
||||
return {
|
||||
sentence: sentence.trim(),
|
||||
prefix: sentence.substring(0, offset).trim(),
|
||||
body: source.trim(),
|
||||
suffix: sentence.substring(offset + source.length).trim()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Audio
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user