1

I have the following test.md:

---
listings: true # here it just seems to include usepackage, but still keeps code blocks in {verbatim}; only --listings on command line starts wrapping code block in lstlisting ?
title: "Some title here"
author: John Doe
date: \today
---

# Introduction

Here is some code output, obtained with the `devcon.exe` command line tool:

```
PCI\VEN_8086&DEV_A295&SUBSYS_36E217AA&REV_F0\3&11583659&0&E0
    Name: Intel(R) 200 Series Chipset Family PCI Express Root Port #6 - A295
    Driver is running.
PCI\VEN_8086&DEV_5912&SUBSYS_36E217AA&REV_04\3&11583659&0&10
    Name: Intel(R) HD Graphics 630
    Driver is running.
ACPI\ACPI000C\2&DABA3FF&1
    Name: ACPI Processor Aggregator
    Driver is running.
```

So ...

So, if I build this as-is with pandoc, the code block is still wrapped in {verbatim} environment, even if \usepackage{listings} is included, due to the presence of listings: true in YAML header:

$ pandoc test.md -s -o test.tex && grep '\\begin\|list' test.tex
\usepackage{listings}
\providecommand{\tightlist}{%
\begin{document}
\begin{verbatim}

Only if I add the --listings switch to the command line, then I have the code block wrapped in {lstlistings} environment:

$ pandoc test.md --listings -s -o test.tex && grep '\\begin\|list' test.tex
\usepackage{listings}
\providecommand{\tightlist}{%
\begin{document}
\begin{lstlisting}
\end{lstlisting}

My question is: is there any way I can just specify the use of listings in the YAML header only -- without having to use the --listings switch in the pandoc call on the command line?

EDIT: this is on pandoc 2.11.4

sdbbs
  • 4,270
  • 5
  • 32
  • 87

1 Answers1

0

There's an open pandoc issue about this.

You can use a wrapper script, or use pandoc's --defaults option, which can be used as follows to specify command-line options from a file. If e.g. input.md contains:

---
listings: true
...

# my title

rest of my document

You can call pandoc as follows:

pandoc --defaults input.md input.md

Yes, currently you have to specify the file twice: once for the --defaults option to read out the YAML, and once as the markdown input file as usual.

mb21
  • 34,845
  • 8
  • 116
  • 142