Ben
Ben

Reputation: 249

Linebreaks removed by pandoc

I am using pandoc to translate from html to markdown.
Pandoc is removing linebreak in the results.

Here is the command I am using:

pandoc -f html -t markdown_phpextra myfile.html

Is there any way for keeping all the linebreaks in the html file ?

Upvotes: 8

Views: 3710

Answers (4)

John MacFarlane
John MacFarlane

Reputation: 8937

Newer pandoc versions support --wrap=preserve.

Old answer:

Pandoc does not distinguish between newlines and other whitespace (outside of <pre> tags), since these are not semantically different in HTML.

Upvotes: 3

martz
martz

Reputation: 849

Digging up an old question since I just discovered that you can specify a Pandoc extension for this:

pandoc -f markdown+hard_line_breaks -t html myfile.html

That worked for me (notice that I used regular markdown, though). See also pandoc's man page for further explanations.

Upvotes: 7

Dilawar
Dilawar

Reputation: 5645

I had the same problem. What I did what to replace each newline with <p></p> string with additional <p> and </p> at the beginning and end. Then I passed the text to pandoc. It worked well.

Upvotes: 0

Shruti Kapoor
Shruti Kapoor

Reputation: 1136

Use <pre> tags wherever whitespace needs to be preserved. Have you tried &nbsp or <br>

Upvotes: 0

Related Questions