diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-09-02 23:19:53 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-09-02 23:20:42 +0100 |
| commit | 9d44fe567d20c5a82c4c2a01673325a31794745b (patch) | |
| tree | bd11998f60330017640c56ac0089c6db4487016d | |
| parent | 6e9740534d364c35b82428cf9f1c2bef970d0f28 (diff) | |
Use alt text title if description is missing
| -rw-r--r-- | NEWS | 5 | ||||
| -rw-r--r-- | lib/docx/body-reader.js | 2 | ||||
| -rw-r--r-- | test/docx/body-reader.tests.js | 13 |
3 files changed, 19 insertions, 1 deletions
@@ -1,3 +1,8 @@ +# 1.2.1 + +* Use alt text title as alt text for images when the alt text description is + missing entirely. + # 1.2.0 * Throw more informative error when word/document.xml cannot be found. diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 519a50b..732a8d2 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -322,7 +322,7 @@ function BodyReader(options) { } function isBlank(value) { - return /^\s*$/.test(value); + return value == null || /^\s*$/.test(value); } function findBlipImageFile(blip) { diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 21ed961..878d279 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -469,6 +469,19 @@ test("can read inline pictures", function() { })))); }); +test("alt text title is used if alt text description is missing", function() { + var drawing = createInlineImage({ + blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID), + title: "It's a hat" + }); + + var result = readEmbeddedImage(drawing); + + return promiseThat(result, isSuccess(contains(isImage({ + altText: "It's a hat" + })))); +}); + test("alt text title is used if alt text description is blank", function() { var drawing = createInlineImage({ blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID), |
