// HTML in a template (issue #2632): patchDocument replaces a placeholder's paragraph with HTML's paragraphs, lists and // tables, and a placeholder in a paragraph with inline HTML. See docs/usage/html.md. import * as fs from "fs"; import { patchDocument, PatchType } from "docx"; import { htmlToContent, htmlToRuns } from "docx/html"; patchDocument({ outputType: "nodebuffer", data: fs.readFileSync("./demo/assets/simple-template.docx"), patches: { name: { type: PatchType.PARAGRAPH, children: [...htmlToRuns("Ada Lovelace")] }, paragraph_replace: { type: PatchType.DOCUMENT, children: [ ...htmlToContent(`
The report, written in an editor:
| Region | Sales |
|---|---|
| EMEA | 1,200 |