ashishb / wp2hugo

The best WordPress to Hugo migrator (written in Go)
Other
16 stars 1 forks source link

HTML to Markdown does not display manual line breaks #12

Open zturtleman opened 3 months ago

zturtleman commented 3 months ago

A list using <br /> to separate lines in WordPress does not display line breaks in the generated Markdown. Adding two spaces to the end of lines with <br /> forces a line break to be displayed. Markdown reference

WordPress XML export:

<!-- wp:paragraph -->
<p>First line<br />Second line<br />Third line</p>
<!-- /wp:paragraph -->

First line
Second line
Third line

Generated by wp2hugo:

First line
Second line
Third line

First line Second line Third line

Adding two spaces to the end of lines with <br /> forces a line break to be displayed:

First line  
Second line  
Third line

First line
Second line
Third line

ashishb commented 3 months ago

@zturtleman

What should be the right output of this?

<!-- wp:paragraph -->
<p>First line<br />Second line<br />Third line</p>
<!-- /wp:paragraph -->

As far as I know, there is no standard way to add non-paragraph line breaks in markdown.

zturtleman commented 3 months ago

For context, \<br /> are generated by WordPress in paragraphs using shift+enter.

From the Markdown standard:

When you do want to insert a \<br /> break tag using Markdown, you end a line with two or more spaces, then type return.

Converting this HTML to Markdown:

<!-- wp:paragraph -->
<p>First line<br />Second line<br />Third line</p>
<!-- /wp:paragraph -->

Should be this Markdown (with two spaces at the end of the first two lines):

First line  
Second line  
Third line

Using + to visual spaces, it would look like this:

First line++
Second line++
Third line

Though the Markdown itself should use spaces, not +.

ashishb commented 1 month ago

Thanks. Would you like to send a PR @zturtleman ?

zturtleman commented 1 month ago

I provided more explanation on an issue for the underlying library. I'm not planning to submit on a PR. It's not urgent for me personally.