diff options
| author | Michael Williamson <mike@zwobble.org> | 2020-08-15 12:33:39 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2020-08-15 12:33:39 +0100 |
| commit | 344cb23aa9fd61b6fc23397bd5566853bd914c5c (patch) | |
| tree | 5b67295ed27e3aa26e074197aa52c18496cfb601 | |
| parent | 8b6a4775f742d0a8b9b18581b0fd94c60b9a4e1d (diff) | |
Move soft hyphen support next to non-breaking hyphen support
| -rw-r--r-- | lib/docx/body-reader.js | 7 | ||||
| -rw-r--r-- | test/docx/body-reader.tests.js | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 12a12c7..e7e306c 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -227,6 +227,9 @@ function BodyReader(options) { "w:noBreakHyphen": function() { return elementResult(new documents.Text("\u2011")); }, + "w:softHyphen": function(element) { + return elementResult(new documents.Text("\u00AD")); + }, "w:hyperlink": function(element) { var relationshipId = element.attributes["r:id"]; var anchor = element.attributes["w:anchor"]; @@ -288,10 +291,6 @@ function BodyReader(options) { return readXmlElements(element.firstOrEmpty("w:sdtContent").children); }, - "w:softHyphen": function(element) { - return elementResult(new documents.Text("\u00AD")); - }, - "w:ins": readChildElements, "w:object": readChildElements, "w:smartTag": readChildElements, diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index afdddfc..48f6b16 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -608,6 +608,12 @@ test("w:noBreakHyphen is read as non-breaking hyphen character", function() { assert.deepEqual(result.value, new documents.Text("\u2011")); }); +test("soft hyphens are read as text", function() { + var element = new XmlElement("w:softHyphen", {}, []); + var text = readXmlElementValue(element); + assert.deepEqual(text, new documents.Text("\u00AD")); +}); + test("w:tbl is read as document table element", function() { var tableXml = new XmlElement("w:tbl", {}, [ new XmlElement("w:tr", {}, [ @@ -1219,12 +1225,6 @@ test("text nodes are ignored when reading children", function() { assert.deepEqual(run, new documents.Run([])); }); -test("soft hyphens are read as text", function() { - var runXml = new XmlElement("w:softHyphen", {}, []); - var text = readXmlElementValue(runXml); - assert.deepEqual(text, new documents.Text("\u00AD")); -}); - function paragraphWithStyleId(styleId) { return new XmlElement("w:p", {}, [ new XmlElement("w:pPr", {}, [ |
