Skip to content

Leading tabs in code block are not retained in org reader with -p #10071

@minyez

Description

@minyez

Explain the problem.
I tried to convert an org-mode file to Markdown. When using pandoc with -p option to preserve the tabs in the Makefile source block, I found the leading tab is converted to single space while the other tabs remain unexpanded.

Minimal example

$ cat example.org
#+begin_src makefile
%.o: %.cpp
	$(CXX)	-o	$@	$<
#+end_src

There is a leading tab and tabs between entries in the directive. When converted to markdown with and without -p

$ pandoc -f org -t json -p example.org
{"pandoc-api-version":[1,23,1],"meta":{},"blocks":[{"t":"CodeBlock","c":[["",["makefile"],[]],"%.o: %.cpp\n $(CXX)\t-o\t$@\t$<\n"]}]}
$ pandoc -f org -t json example.org
{"pandoc-api-version":[1,23,1],"meta":{},"blocks":[{"t":"CodeBlock","c":[["",["makefile"],[]],"%.o: %.cpp\n    $(CXX)  -o  $@  $<\n"]}]}

On the other hand, the markdown reader seems fine (I don't know how to make markdown block within a code block correctly rendered, so I added a comma before backticks)

$ cat example.md
,```makefile
%.o: %.cpp
	$(CXX)	-o	$@	$<
,```
$ pandoc -f markdown -t json -p example.md
{"pandoc-api-version":[1,23,1],"meta":{},"blocks":[{"t":"CodeBlock","c":[["",["makefile"],[]],"%.o: %.cpp\n\t$(CXX)\t-o\t$@\t$<"]}]}
$ pandoc -f markdown -t json example.md
{"pandoc-api-version":[1,23,1],"meta":{},"blocks":[{"t":"CodeBlock","c":[["",["makefile"],[]],"%.o: %.cpp\n    $(CXX)  -o  $@  $<"]}]}

Expected behavior

$ pandoc -f org -t json -p example.org
{"pandoc-api-version":[1,23,1],"meta":{},"blocks":[{"t":"CodeBlock","c":[["",["makefile"],[]],"%.o: %.cpp\n\t$(CXX)\t-o\t$@\t$<\n"]}]}

Pandoc version?
pandoc is installed using homebrew on macOS Sonoma

$ pandoc --version
pandoc 3.3
Features: +server +lua
Scripting engine: Lua 5.4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions