Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.22k stars 968 forks source link

firstnumber / startFrom support #142

Closed tott closed 4 years ago

tott commented 4 years ago

Thanks a lot for the great template. I'm struggling a bit to pass over the startFrom / firstnumber to the latex lstlisting block.

Based on https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs#L640 the following should be supported

~~~~ {.sourceCode .haskell .numberLines startFrom="100"}
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
               qsort (filter (>= x) xs)
~~~~

However the additional parameters are not passed through to the lstlisting block and it would only render like this

\begin{lstlisting}
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
               qsort (filter (>= x) xs)
\end{lstlisting}

I'd be happy for any guidance or suggestions.

Wandmalfarbe commented 4 years ago

What command are you using to compile the document? What version of pandoc?

My result looks like this:

\begin{lstlisting}[language=Haskell, numbers=left, firstnumber=100]
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
               qsort (filter (>= x) xs)
\end{lstlisting}

with the following command:

pandoc --from markdown --to latex --template eisvogel --listings test.md
tott commented 4 years ago

Thanks for the follow-up. I meanwhile narrowed it down to the markdown variant i was using. I was initially working with 'gfm' which did not work but when switching to pandoc 'markdown' as from format things work as expected. This can be closed.