diff --git a/src/language-markdown/printer-markdown.js b/src/language-markdown/printer-markdown.js index 497eb349d..9a0fb218c 100644 --- a/src/language-markdown/printer-markdown.js +++ b/src/language-markdown/printer-markdown.js @@ -284,7 +284,7 @@ function genericPrint(path, options, print) { case "imageReference": switch (node.referenceType) { case "full": - return concat(["![", node.alt, "][", node.identifier, "]"]); + return concat(["![", node.alt || "", "][", node.identifier, "]"]); default: return concat([ "![", diff --git a/tests/markdown_imageReference/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_imageReference/__snapshots__/jsfmt.spec.js.snap index 399f3c8a0..8dc23177f 100644 --- a/tests/markdown_imageReference/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_imageReference/__snapshots__/jsfmt.spec.js.snap @@ -14,6 +14,13 @@ exports[`full.md 1`] = ` `; +exports[`full-no-alt.md 1`] = ` +![][world] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +![][world] + +`; + exports[`shortcut.md 1`] = ` ![hello] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/markdown_imageReference/full-no-alt.md b/tests/markdown_imageReference/full-no-alt.md new file mode 100644 index 000000000..140233b65 --- /dev/null +++ b/tests/markdown_imageReference/full-no-alt.md @@ -0,0 +1 @@ +![][world]