Search code examples
htmlmarkdownindentationpandoc

Pandoc, markdown to html, how to use tab indentation in code area?


My source code is indented with Tab. But in the html generated by pandoc, the code is indented by 4 spaces.

Is there any options to control how to indent? Or is it possible to let pandoc just copy the code?

(Because the code with tab indentation is changed into spaecs in stack overflow, so the example is shown as images.)

Markdown:

markdown,

HTML:

html.


Solution

  • Yes, this is possible.

    From the pandoc documentation available at: https://pandoc.org/MANUAL.html

    -p, --preserve-tabs

    Preserve tabs instead of converting them to spaces. (By default, pandoc converts tabs to spaces before parsing its input.) Note that this will only affect tabs in literal code spans and code blocks. Tabs in regular text are always treated as spaces.

    Just pass pandoc this argument.