diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-04 09:31:31 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-04 09:31:31 -0800 |
commit | 0bbee1bcf68bfb7d19b1d4230292004670286ed2 (patch) | |
tree | 59f20dd6eb8ecc40ec2bc6e3d5e08529cba14815 /src/Text | |
parent | b2b38a6c0f3fb7c866f99125fcd7bac3f95928f6 (diff) | |
download | pandoc-0bbee1bcf68bfb7d19b1d4230292004670286ed2.tar.gz |
LaTeX writer: Support line numbering with `--listings`.
If "numberLines" class is present, we add "numbers=left";
if "startFrom" is present, we add "firstnumber=".
Partially addresses #763.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 3c700b936..2e9f2f028 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -332,11 +332,17 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do then (case getListingsLanguage classes of Just l -> [ "language=" ++ l ] Nothing -> []) ++ - [ key ++ "=" ++ attr | (key,attr) <- keyvalAttr ] + [ "numbers=left" | "numberLines" `elem` classes + || "number" `elem` classes + || "number-lines" `elem` classes ] ++ + [ (if key == "startFrom" + then "firstnumber" + else key) ++ "=" ++ attr | + (key,attr) <- keyvalAttr ] else [] printParams | null params = empty - | otherwise = brackets $ hsep (intersperse "," (map text params)) + | otherwise = brackets $ hcat (intersperse ", " (map text params)) return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$ "\\end{lstlisting}") $$ cr highlightedCodeBlock = |