Alir3z4 / html2text

Convert HTML to Markdown-formatted text.
alir3z4.github.io/html2text/
GNU General Public License v3.0
1.74k stars 266 forks source link

Strip leading/trailing whitespace for links and inline code #376

Open kevinoid opened 2 years ago

kevinoid commented 2 years ago

It would be great if the fix from #177 for #142, which strips leading and trailing whitespace for emphasis/strong/underline/strikethrough, could also be applied to links and inline code where leading and trailing space is stripped for white-space: normal.

html2text.html2text('<a href="https://example.com">\nExample\n</a>')
'[ Example ](https://example.com)\n\n'
>>> html2text.html2text('<code>\nx = 1\n</code>')
'` x = 1 `\n\n'

Related: #371

Thanks, Kevin

kevinoid commented 2 years ago

Potential duplicate (at least for inline links, if not code): #329