Python-Markdown / markdown

A Python implementation of John Gruber’s Markdown with Extension support.
https://python-markdown.github.io/
BSD 3-Clause "New" or "Revised" License
3.79k stars 863 forks source link

Spaces added after markdown tokens and links #1237

Closed masasin closed 2 years ago

masasin commented 2 years ago

Hello,

If I write something like this:

_italic_, *bold*, and [a link](https://github.com).

I get spaces in the final output:

italic , bold , and a link .

I would expect:

italic, bold, and a link.

It looks like the html tags are on their separate lines whenever we have a markdown token, and I'm wondering if there's a way to change that behaviour.

facelessuser commented 2 years ago

I'm not seeing any spaces, maybe it has to do with your HTML styling adding padding or margins:

>>> import markdown
>>> markdown.__version__
'3.3.6'
>>> markdown.markdown('_italic_, *bold*, and [a link](https://github.com).')
'<p><em>italic</em>, <em>bold</em>, and <a href="https://github.com">a link</a>.</p>'
masasin commented 2 years ago

You were right. It was caused by bs4.prettify(). I'll close this issue.