In MS Word 2015 (and possibly others), leading and trailing spaces are ignored in text runs. This means that calling TextRun with leading/trailing space would result in a document that didn't include those spaces. The fix here (per http://officeopenxml.com/WPtext.php) is to include an extra attribute on the "w:t" element that forces word to recognize those spaces.
20 lines
558 B
TypeScript
20 lines
558 B
TypeScript
import { expect } from "chai";
|
|
import { TextRun } from "../../../docx/run/text-run";
|
|
import { Formatter } from "../../../export/formatter";
|
|
|
|
describe("TextRun", () => {
|
|
let run: TextRun;
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should add text into run", () => {
|
|
run = new TextRun("test");
|
|
const f = new Formatter().format(run);
|
|
expect(f).to.deep.equal({"w:r": [
|
|
{"w:rPr": []},
|
|
{"w:t": [{_attr: {"xml:space": "preserve"}}, "test"]},
|
|
]});
|
|
});
|
|
});
|
|
});
|