fix text extraction for cells with partial styling (#23)
This commit is contained in:
parent
02d5338634
commit
90b97e23e9
@ -33,7 +33,7 @@ function extraxtODSCellText(cell) {
|
|||||||
text += pChild.nodeValue; // Append text inside <text:p>
|
text += pChild.nodeValue; // Append text inside <text:p>
|
||||||
} else if (pChild.nodeName === 'text:line-break') {
|
} else if (pChild.nodeName === 'text:line-break') {
|
||||||
text += '\n'; // Append newline for <text:line-break />
|
text += '\n'; // Append newline for <text:line-break />
|
||||||
} else if (pChild.nodeName === 'text:a') {
|
} else if (pChild.nodeName === 'text:a' || pChild.nodeName === 'text:span') {
|
||||||
text += pChild.textContent
|
text += pChild.textContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
tests/fixtures/cellule avec style.ods
vendored
Normal file
BIN
tests/fixtures/cellule avec style.ods
vendored
Normal file
Binary file not shown.
@ -76,3 +76,13 @@ test('.ods cells with mails should be recognized', async t => {
|
|||||||
t.deepEqual(row3[0].value, 'Fanny')
|
t.deepEqual(row3[0].value, 'Fanny')
|
||||||
t.deepEqual(row3[1].value, 'lemaildeFanny@example.com')
|
t.deepEqual(row3[1].value, 'lemaildeFanny@example.com')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('.ods cells with partially styled content should be recognized', async t => {
|
||||||
|
const odsFileWithStyle = (await readFile('./tests/fixtures/cellule avec style.ods')).buffer;
|
||||||
|
const table = await getODSTableRawContent(odsFileWithStyle);
|
||||||
|
|
||||||
|
const feuille1 = table.get('Feuille1');
|
||||||
|
|
||||||
|
const row1 = feuille1[0];
|
||||||
|
t.deepEqual(row1[0].value, 'Toto titi');
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user