Preserve QWord subscript superscript in DOCX

This commit is contained in:
Курнат Андрей
2026-06-02 07:24:42 +03:00
parent 7ace47dd2a
commit b8c347142a
4 changed files with 100 additions and 3 deletions
+23
View File
@@ -128,6 +128,29 @@ describe("wordOffice DOCX import", () => {
]);
});
it("imports DOCX subscript and superscript from OOXML", async () => {
const blob = await exportDocxBlob("Indexes.docx", "<p>H<sub>2</sub>O m<sup>2</sup></p>");
const file = new File([blob], "Indexes.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
});
const imported = await importDocxFile(file);
expect(imported.html).toContain("<sub>2</sub>");
expect(imported.html).toContain("<sup>2</sup>");
expect(htmlToWordBlocks(imported.html)).toEqual([
{
type: "paragraph",
text: "H2O m2",
runs: [
{ text: "H" },
{ text: "2", subscript: true },
{ text: "O m" },
{ text: "2", superscript: true }
]
}
]);
});
it("imports DOCX line breaks from OOXML", async () => {
const blob = await exportDocxBlob("LineBreak.docx", "<p>Line 1<br>Line 2</p>");
const file = new File([blob], "LineBreak.docx", {