Preserve QWord line breaks in DOCX
This commit is contained in:
@@ -52,6 +52,18 @@ describe("wordOffice helpers", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("сохраняет HTML-переносы строк как inline runs для DOCX", () => {
|
||||
const blocks = htmlToWordBlocks("<p>Line 1<br>Line 2<br><strong>Line 3</strong></p>");
|
||||
|
||||
expect(blocks).toEqual([
|
||||
{
|
||||
type: "paragraph",
|
||||
text: "Line 1 Line 2 Line 3",
|
||||
runs: [{ text: "Line 1\nLine 2\n" }, { text: "Line 3", bold: true }]
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("сохраняет выравнивание абзацев и заголовков для DOCX", () => {
|
||||
const blocks = htmlToWordBlocks(`
|
||||
<h1 align="right">Итоги</h1>
|
||||
@@ -123,6 +135,15 @@ describe("wordOffice helpers", () => {
|
||||
expect(documentXml).toContain("<w:u");
|
||||
});
|
||||
|
||||
it("записывает HTML-переносы строк как w:br в XML экспортированного DOCX", async () => {
|
||||
const blob = await exportDocxBlob("Переносы.docx", "<p>Line 1<br>Line 2</p>");
|
||||
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
|
||||
const documentXml = await zip.file("word/document.xml")?.async("string");
|
||||
|
||||
expect(documentXml).toContain("<w:br/>");
|
||||
expect(documentXml).toMatch(/<w:t[^>]*>Line 1<\/w:t>[\s\S]*<w:br\/>[\s\S]*<w:t[^>]*>Line 2<\/w:t>/);
|
||||
});
|
||||
|
||||
it("записывает цвет текста и подсветку в XML экспортированного DOCX", async () => {
|
||||
const blob = await exportDocxBlob(
|
||||
"Цвет.docx",
|
||||
|
||||
Reference in New Issue
Block a user