Support video tag with poster attribute (#189)
This commit is contained in:
@@ -538,6 +538,24 @@ class MarkdownConverter(object):
|
||||
|
||||
return '' % (alt, src, title_part)
|
||||
|
||||
def convert_video(self, el, text, parent_tags):
|
||||
if ('_inline' in parent_tags
|
||||
and el.parent.name not in self.options['keep_inline_images_in']):
|
||||
return text
|
||||
src = el.attrs.get('src', None) or ''
|
||||
if not src:
|
||||
sources = el.find_all('source', attrs={'src': True})
|
||||
if sources:
|
||||
src = sources[0].attrs.get('src', None) or ''
|
||||
poster = el.attrs.get('poster', None) or ''
|
||||
if src and poster:
|
||||
return '[](%s)' % (text, poster, src)
|
||||
if src:
|
||||
return '[%s](%s)' % (text, src)
|
||||
if poster:
|
||||
return '' % (text, poster)
|
||||
return text
|
||||
|
||||
def convert_list(self, el, text, parent_tags):
|
||||
|
||||
# Converting a list to inline is undefined.
|
||||
|
||||
@@ -243,6 +243,14 @@ def test_img():
|
||||
assert md('<img src="/path/to/img.jpg" alt="Alt text" />') == ''
|
||||
|
||||
|
||||
def test_video():
|
||||
assert md('<video src="/path/to/video.mp4" poster="/path/to/img.jpg">text</video>') == '[](/path/to/video.mp4)'
|
||||
assert md('<video src="/path/to/video.mp4">text</video>') == '[text](/path/to/video.mp4)'
|
||||
assert md('<video><source src="/path/to/video.mp4"/>text</video>') == '[text](/path/to/video.mp4)'
|
||||
assert md('<video poster="/path/to/img.jpg">text</video>') == ''
|
||||
assert md('<video>text</video>') == 'text'
|
||||
|
||||
|
||||
def test_kbd():
|
||||
inline_tests('kbd', '`')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user