Skip to content

Commit 828e116

Browse files
committed
add figure/figcaption
for matthewwithanm#46
1 parent 62e9f0d commit 828e116

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

markdownify/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ def convert_code(self, el, text, convert_as_inline):
240240

241241
convert_em = abstract_inline_conversion(lambda self: self.options['strong_em_symbol'])
242242

243+
def convert_figcaption(self, el, text, convert_as_inline):
244+
return "<figcaption>%s</figcaption>" % text
245+
246+
def convert_figure(self, el, text, convert_as_inline):
247+
return "<figure>%s</figure>" % text
248+
243249
convert_kbd = convert_code
244250

245251
def convert_hn(self, n, el, text, convert_as_inline):

tests/test_conversions.py

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def test_a_no_autolinks():
3939
assert md('<a href="https://google.com">https://google.com</a>', autolinks=False) == '[https://google.com](https://google.com)'
4040

4141

42+
def test_a_containing_images():
43+
assert md('<a href="#"><img src="/path/to/img.jpg"></a>') == '[![](/path/to/img.jpg)](#)'
44+
45+
4246
def test_b():
4347
assert md('<b>Hello</b>') == '**Hello**'
4448

@@ -84,6 +88,10 @@ def test_em():
8488
inline_tests('em', '*')
8589

8690

91+
def test_figure():
92+
assert md('<figure><img src="#"><figcaption>A</figcaption></figure>') == '<figure>![](#)<figcaption>A</figcaption></figure>'
93+
94+
8795
def test_h1():
8896
assert md('<h1>Hello</h1>') == 'Hello\n=====\n\n'
8997

0 commit comments

Comments
 (0)