diff --git a/markdownify/__init__.py b/markdownify/__init__.py index cb12d43..2cd8fc8 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -229,6 +229,9 @@ class MarkdownConverter(object): src = el.attrs.get('src', None) or '' title = el.attrs.get('title', None) or '' title_part = ' "%s"' % title.replace('"', r'\"') if title else '' + if convert_as_inline: + return alt + return '' % (alt, src, title_part) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index ab1ce05..f5fc1c2 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -107,12 +107,42 @@ def test_hn(): assert md('
P
C ') == '### A P C\n\n' +def test_hn_nested_tag_heading_style(): assert md('P
C ', heading_style=ATX_CLOSED) == '# A P C #\n\n' assert md('P
C ', heading_style=ATX) == '# A P C\n\n' - assert md('BQC
') == ''
+ assert md('
') == ''
+ image_attributes_to_markdown = [
+ ("", ""),
+ ("alt='Alt Text'", "Alt Text"),
+ ("alt='Alt Text' title='Optional title'", "Alt Text"),
+ ]
+ for image_attributes, markdown in image_attributes_to_markdown:
+ assert md('
B