diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-08 20:39:42 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-08 20:39:42 +0000 |
| commit | a098466259ce25c82f5c5faa5b2dcd3b9c8f90d6 (patch) | |
| tree | 945901d77009e99c761e6cc1d4c3b54ea8c0f8e8 | |
| parent | d6494f9fe0d2265167295c4d813173945fd505cf (diff) | |
Handle image elements with no src in markdown writer
| -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 6db4ea9..5e3cf00 100644 --- a/mammoth/writers/markdown.py +++ b/mammoth/writers/markdown.py @@ -35,7 +35,7 @@ def _hyperlink(attributes): def _image(attributes): - src = attributes.get("src") + src = attributes.get("src", "") 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 94fcd06..f0e4ba0 100644 --- a/tests/writers/markdown_tests.py +++ b/tests/writers/markdown_tests.py @@ -124,6 +124,13 @@ 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()) + + +@istest +def images_are_written_even_if_they_dont_have_a_src_attribute(): + writer = _create_writer() + writer.self_closing("img", {"alt": "Alt Text"}) + assert_equal("![Alt Text]()", writer.as_string()) def _create_writer(): |
