Evidlo / markdown_captions

Python-Markdown plugin for image captions
GNU General Public License v3.0
9 stars 5 forks source link

Fiigures in the same paragraph with attributes are parsed incorrectly #4

Closed scossu closed 2 years ago

scossu commented 3 years ago

If I have two or more figures separated by only one newline (or even no newline) and the first one has CSS attributes, the second one is not displayed.

Steps to reproduce:

$ pip list | grep -i markdown
Markdown              3.3.4
markdown-captions     2
markdown-customblocks 1.1.1
$ python
Python 3.9.7 (default, Oct 10 2021, 15:13:22) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import markdown
>>> ext = ['attr_list', 'markdown_captions']
>>> # Note that img2 is not rendered.
>>> md1 = '![image 1](/media/images/img1.jpg){: .float-left }\n![image 2](/media/images/img2.jpg){: .float-left }\n'
>>> markdown.markdown(md1, extensions=ext)
'<p>\n<figure class="float-left"><img src="/media/images/img1.jpg" /><figcaption>image 1</figcaption></figure>\n</p>'
>>> # Note that img2 is rendered correctly if I remove the attribute list from the first figure.
>>> md2 =  '![image 1](/media/images/img1.jpg)\n![image 2](/media/images/img2.jpg){: .float-left }\n'
>>> markdown.markdown(md2, extensions=ext)
'<p>\n<figure><img src="/media/images/img1.jpg" /><figcaption>image 1</figcaption>\n</figure>\n<figure class="float-left"><img src="/media/images/img2.jpg" /><figcaption>image 2</figcaption></figure>\n</p>'
>>> # Figures in isolated paragraphs render correctly, however not as I want them rendered.
>>> md3 =  '![image 1](/media/images/img1.jpg){: .float-left }\n\n![image 2](/media/images/img2.jpg){: .float-left }\n'
>>> markdown.markdown(md3, extensions=ext)
'<p>\n<figure class="float-left"><img src="/media/images/img1.jpg" /><figcaption>image 1</figcaption></figure>\n</p>\n<p>\n<figure class="float-left"><img src="/media/images/img2.jpg" /><figcaption>image 2</figcaption></figure>\n</p>'

Not sure if this is a specific issue with markdown_captions or with attribute_list. Any help would be greatly appreciated.

Evidlo commented 2 years ago

This should be fixed with 2.0.1. Let me know what you think.

scossu commented 2 years ago

This works as expected now. Thank you very much.