mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-01 00:15:28 -07:00
fix(anki): preserve one-sided Senren furigana
This commit is contained in:
@@ -394,7 +394,7 @@ test('Senren merge closes unclosed group spans so later scenes stay siblings', a
|
|||||||
assert.equal(openTags, closeTags);
|
assert.equal(openTags, closeTags);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('computeFieldGroupingMergedFields 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();
|
||||||
|
|
||||||
const merged = await collaborator.computeFieldGroupingMergedFields(
|
const merged = await collaborator.computeFieldGroupingMergedFields(
|
||||||
@@ -411,3 +411,21 @@ test('computeFieldGroupingMergedFields clears SentenceFurigana when either note
|
|||||||
|
|
||||||
assert.equal(merged.SentenceFurigana, '');
|
assert.equal(merged.SentenceFurigana, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Senren merge keeps duplicate SentenceFurigana when the kept field is empty', async () => {
|
||||||
|
const { collaborator } = createCollaborator({ fieldGroupingProvider: 'senren' });
|
||||||
|
|
||||||
|
const merged = await collaborator.computeFieldGroupingMergedFields(
|
||||||
|
300,
|
||||||
|
200,
|
||||||
|
makeNote(300, {
|
||||||
|
SentenceFurigana: '',
|
||||||
|
}),
|
||||||
|
makeNote(200, {
|
||||||
|
SentenceFurigana: 'duplicate furigana',
|
||||||
|
}),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(merged.SentenceFurigana, '<span class="group">duplicate furigana</span>');
|
||||||
|
});
|
||||||
|
|||||||
@@ -162,8 +162,11 @@ export class FieldGroupingMergeCollaborator {
|
|||||||
if (!existingValue.trim() && !newValue.trim()) continue;
|
if (!existingValue.trim() && !newValue.trim()) continue;
|
||||||
|
|
||||||
if (keepFieldNormalized === 'sentencefurigana') {
|
if (keepFieldNormalized === 'sentencefurigana') {
|
||||||
|
const hasBothValues = existingValue.trim().length > 0 && newValue.trim().length > 0;
|
||||||
|
const usesSenrenGrouping =
|
||||||
|
this.deps.getEffectiveSentenceCardConfig().fieldGroupingProvider === 'senren';
|
||||||
mergedFields[keepFieldName] =
|
mergedFields[keepFieldName] =
|
||||||
existingValue.trim() && newValue.trim()
|
hasBothValues || usesSenrenGrouping
|
||||||
? this.applyFieldGrouping(
|
? this.applyFieldGrouping(
|
||||||
existingValue,
|
existingValue,
|
||||||
newValue,
|
newValue,
|
||||||
|
|||||||
Reference in New Issue
Block a user