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.
This commit is contained in:
John MacFarlane 2013-03-04 09:31:31 -08:00
parent b2b38a6c0f
commit 0bbee1bcf6

View file

@ -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 =