diff options
| -rw-r--r-- | mammoth/writers/markdown.py | 2 | ||||
| -rw-r--r-- | tests/writers/markdown_tests.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/mammoth/writers/markdown.py b/mammoth/writers/markdown.py index 4aa73d5..6db4ea9 100644 --- a/mammoth/writers/markdown.py +++ b/mammoth/writers/markdown.py @@ -36,7 +36,7 @@ def _hyperlink(attributes): def _image(attributes): src = attributes.get("src") - alt_text = attributes.get("alt") + alt_text = attributes.get("alt", "") return _WriterOutput("".format(alt_text, src), "") diff --git a/tests/writers/markdown_tests.py b/tests/writers/markdown_tests.py index dd25818..94fcd06 100644 --- a/tests/writers/markdown_tests.py +++ b/tests/writers/markdown_tests.py @@ -117,6 +117,13 @@ def image_elements_are_written_as_markdown_images(): writer = _create_writer() writer.self_closing("img", {"src": "http://example.com/image.jpg", "alt": "Alt Text"}) assert_equal("", writer.as_string()) + + +@istest +def images_are_written_even_if_they_dont_have_alt_text(): + writer = _create_writer() + writer.self_closing("img", {"src": "http://example.com/image.jpg"}) + assert_equal("", writer.as_string()) def _create_writer(): |
