From a6233fafe736ff9abbdfe88f7f702ebd63ee4608 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 9 Feb 2015 20:37:31 +0000 Subject: Ignore _GoBack bookmarks at parse-time --- lib/docx/document-xml-reader.js | 10 +++++++--- tests/document-to-html.tests.js | 8 -------- tests/docx/document-xml-reader.tests.js | 6 ++++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js index f25e7a3..7a0dd8a 100644 --- a/lib/docx/document-xml-reader.js +++ b/lib/docx/document-xml-reader.js @@ -200,9 +200,13 @@ function DocumentXmlReader(options) { }, "w:bookmarkStart": function(element){ var name = element.attributes["w:name"]; - return readXmlElements(element.children).map(function(){ - return new documents.BookmarkStart({name: name}); - }); + if (name === "_GoBack") { + return new Result([]); + } else { + return readXmlElements(element.children).map(function(){ + return new documents.BookmarkStart({name: name}); + }); + } }, "w:ins": readChildElements, diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 4863cf1..46f5649 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -429,14 +429,6 @@ describe('DocumentConverter', function() { assert.equal(result.value, 'Hello.'); }); }); - - test('unreferenced bookmarks are not converted', function() { - var bookmarkStart = new documents.BookmarkStart({name: "_Unreferenced"}); - var converter = new DocumentConverter(); - return converter.convertToHtml(bookmarkStart).then(function(result) { - assert.equal(result.value, ''); - }); - }); }); function paragraphOfText(text, styleId, styleName) { diff --git a/tests/docx/document-xml-reader.tests.js b/tests/docx/document-xml-reader.tests.js index 35c806b..536f47b 100644 --- a/tests/docx/document-xml-reader.tests.js +++ b/tests/docx/document-xml-reader.tests.js @@ -225,6 +225,12 @@ describe("readXmlElement: ", function() { assert.deepEqual(result.value.type, "bookmarkStart"); }); + test('_GoBack bookmark is ignored', function() { + var bookmarkStart = new XmlElement("w:bookmarkStart", {"w:name": "_GoBack"}); + var result = readXmlElement(bookmarkStart); + assert.deepEqual(result.value, []); + }); + test("can read inline pictures", function() { var drawing = createInlineImage({ relationshipId: "rId5", -- cgit v1.2.3