diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-23 18:37:52 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-23 18:37:52 -0800 |
commit | cc18291baf863a59fb17a63c5c09d69da8c86b01 (patch) | |
tree | 9d95068e012263d066352e7d0293ac59aa3bbaa0 /src | |
parent | 77815c63db258e6c5362ec29bd3ee42b7f7651ba (diff) | |
download | pandoc-cc18291baf863a59fb17a63c5c09d69da8c86b01.tar.gz |
LaTeX writer: Support highlighting for inline code.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 28bffef2d..cb7df6b8a 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -395,14 +395,24 @@ inlineToLaTeX (Cite cits lst) = do Biblatex -> citationsToBiblatex cits _ -> inlineListToLaTeX lst -inlineToLaTeX (Code _ str) = do - st <- get - if writerListings (stOptions st) - then do - when (stInNote st) $ modify $ \s -> s{ stVerbInNote = True } - let chr = ((enumFromTo '!' '~') \\ str) !! 0 - return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr] - else return $ text $ "\\texttt{" ++ stringToLaTeX False str ++ "}" +inlineToLaTeX (Code (_,classes,_) str) = do + opts <- gets stOptions + case () of + _ | writerListings opts -> listingsCode + | writerHighlight opts && not (null classes) -> highlightCode + | otherwise -> rawCode + where listingsCode = do + inNote <- gets stInNote + when inNote $ modify $ \s -> s{ stVerbInNote = True } + let chr = ((enumFromTo '!' '~') \\ str) !! 0 + return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr] + highlightCode = do + case highlightLaTeX True ("",classes,[]) str of + Nothing -> rawCode + Just h -> modify (\st -> st{ stHighlighting = True }) >> + return (text h) + rawCode = return + $ text $ "\\texttt{" ++ stringToLaTeX False str ++ "}" inlineToLaTeX (Quoted SingleQuote lst) = do contents <- inlineListToLaTeX lst csquotes <- liftM stCsquotes get |