Skip to content

pandoc micro tip: disabling line wrap / newlines

  • by

January wrap-up

Since this doesn’t appear in my own previous ‘tips to myself‘ I’m documenting it to myself here:

The option for disabling wrapping is: --wrap=none|preserve (default: auto)

pandoc will try to auto-wrap to a column width of 72. Much as I appreciate short lines, I don’t know why this is the default as it changes output when converting to markdown, for example.

Previously I would re-join lines (vim: J, emacs: M-^ or similar) but that’s unnecessary busywork.

Since pandoc doesn’t seem to have any way of setting defaults, you have to specify this with each conversion (!!!). Alternatively, you could define an alias, which is what I did: alias pandoc="pandoc --wrap=preserve"

From the manual:


Determine how text is wrapped in the output (the source code, not the rendered version). With auto (the default), pandoc will attempt to wrap lines to the column width specified by --columns (default 72). With none, pandoc will not wrap lines at all. With preserve, pandoc will attempt to preserve the wrapping from the source document (that is, where there are nonsemantic newlines in the source, there will be nonsemantic newlines in the output as well). In ipynb output, this option affects wrapping of the contents of markdown cells.

Tell us what's on your mind

Discover more from Rob's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading