add option to allow inline images in selected tags

fixes #61
This commit is contained in:
AlexVonB
2022-04-13 19:55:34 +02:00
parent ed3eee78d2
commit 423b7e948c
3 changed files with 16 additions and 6 deletions

View File

@@ -75,6 +75,7 @@ class MarkdownConverter(object):
default_title = False
escape_underscores = True
heading_style = UNDERLINED
keep_inline_images_in = []
newline_style = SPACES
strip = None
strong_em_symbol = ASTERISK
@@ -278,7 +279,8 @@ 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:
if (convert_as_inline
and el.parent.name not in self.options['keep_inline_images_in']):
return alt
return '![%s](%s%s)' % (alt, src, title_part)