showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.19k stars 1.56k forks source link

makeMarkdown inserts newline where it's not supposed to #953

Open diogen737 opened 1 year ago

diogen737 commented 1 year ago

The makeMarkdown method inserts two newline symbols after each html-like block in the resulting markdown (\<sub> in this example, but also with \<s> and \<u>).

Input:

<p>wtf? and <strong><em>bold</em></strong> again <sub>and</sub> again</p>

Expected output:

wtf? and ***bold*** again <sub>and</sub> again\n\n

Output:

wtf? and ***bold*** again <sub>and</sub>\n\n again\n\n
layaxx commented 1 year ago

Pretty sure this is caused by https://github.com/showdownjs/showdown/blob/95255984ad80acf745ed74605bd3ad8357dc9b33/src/subParsers/makemarkdown/node.js#L121 Adding this blank line should probably be conditional on the node being a block-level element