Using pandoc like:
pandoc -o output.pdf input.md
does not give me a result with word-wrapping.
For instance, three liner input.md looks like the following:
# Introduction
Lorem ipsum dolor sit amet, scelerisque natoque, in etiam erat nibh lacus, porta quam penatibus, at metus, purus leo est. Sed faucibus odio in amet, in sapien ut sapien eu, vehicula pede vel pellentesque, ut hac lacinia mauris ridiculus rhoncus ligula. Sit congue, ac montes, lorem ligula etiam ac fusce ipsum, lacus dolor in suscipit aliquet vitae. Blandit neque aliquam, amet vel, ante nullam neque. Adipiscing nullam, neque elit, nunc non mauris libero vivamus tortor.
running the above command yields a pdf document with some content as the following:
Introduction
Lorem ipsum dolor sit amet, scelerisque natoque, in etiam erat nibh lacus,
Is there a fast way of converting a markdown(.md) file to pdf with word-wrapping (similar to the way done in here)?
Markdown to PDF
With Pandoc
On my Ubuntu 20.04:
If you get the error
install the huge (~600 MB) package
Markdown to HTML from/to clipboard
You can also:
to get formatted HTML to clipboard. If you have the Markdown text on clipboard replace thisOutputMarkdown with
xsel -b
.With
markdown-pdf
NodeJS packageI just convert from HTML instead. This works for my needs:
https://github.com/dompdf/dompdf
I found that in general Markdown is not a good format to convert to PDF, as it doesnt have native CSS support. Here is the script I use:
This solution just needs PHP (25 MB) and DomPdf (4 MB), so quite lightweight compared to other options.