fix(anki): close trailing Senren markup

This commit is contained in:
2026-09-01 00:51:36 -07:00
parent 8eba6d11f9
commit d1ce70dbd0
2 changed files with 19 additions and 1 deletions
@@ -394,6 +394,24 @@ test('Senren merge closes unclosed group spans so later scenes stay siblings', a
assert.equal(openTags, closeTags); assert.equal(openTags, closeTags);
}); });
test('Senren merge closes unclosed trailing markup before appending later scenes', async () => {
const { collaborator } = createCollaborator({ fieldGroupingProvider: 'senren' });
const merged = await collaborator.computeFieldGroupingMergedFields(
300,
200,
makeNote(300, { miscInfo: 'leading<span class="highlight">tail' }),
makeNote(200, { miscInfo: '<span class="group">next</span>' }),
false,
);
assert.equal(
merged.miscInfo,
'<span class="group">leading<span class="highlight">tail</span></span>' +
'<span class="group">next</span>',
);
});
test('Kiku merge clears SentenceFurigana when either note lacks it', async () => { test('Kiku merge clears SentenceFurigana when either note lacks it', async () => {
const { collaborator } = createCollaborator(); const { collaborator } = createCollaborator();
+1 -1
View File
@@ -441,7 +441,7 @@ export class FieldGroupingMergeCollaborator {
// markup) so the following scenes are siblings rather than nested inside it. // markup) so the following scenes are siblings rather than nested inside it.
entries.push(`${value.slice(entryStart)}${'</span>'.repeat(depth)}`); entries.push(`${value.slice(entryStart)}${'</span>'.repeat(depth)}`);
} else { } else {
pushUngrouped(value.slice(cursor)); pushUngrouped(`${value.slice(cursor)}${'</span>'.repeat(depth)}`);
} }
return entries; return entries;
} }