python-markdownify icon indicating copy to clipboard operation
python-markdownify copied to clipboard

ensure paragraph start tags begin a paragraph

Open mirabilos opened this issue 1 year ago • 2 comments
trafficstars

Fixes #92 and is the only remaining code change I have (as opposed to wrapping Markdownify)

mirabilos avatar Jan 31 '24 23:01 mirabilos

Hi! This breaks some working code, as there will be a few places with loads of empty lines, for example:

md('<blockquote><p>Hello</p><p>Hello again</p></blockquote>')


       > Hello
       > 
       > 
       > 
       > Hello again

AlexVonB avatar Mar 26 '24 20:03 AlexVonB

AlexVonB dixit:

Hi! This breaks some working code, as there will be a few places with loads of empty lines, for example:

md('

Hello

Hello again

')
      > Hello
      > 
      > 
      > 
      > Hello again

Postprocess. It’s trivial, and easier to fix there than in Markdownify.

[…]
# convert and clean up
text = MarkdownConverter(strip=['img']).convert_soup(html)
text = re.sub('  \n  \n', '\n\n', '\n' + text + '\n')
text = re.sub('(\n> )+\n', '\n> \n', '\n' + text + '\n')
text = re.sub(' *\n\n+', '\n\n', text)
return text.strip()

mirabilos avatar Mar 26 '24 21:03 mirabilos