diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-03-13 11:38:19 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-03-13 11:38:19 +0100 |
commit | db37b71d9a12bbd9370d68a472a0553f07661aec (patch) | |
tree | ca44f880078cbfde9a76fc6598c6a4d36f1c4dbc /src/Text/Pandoc/Writers/LaTeX.hs | |
parent | efcb51bcb01b5f07d0957fdac7f73e366d9f8c85 (diff) |
Highlighting: highlighting now returns an Either rather than Maybe.
This allows us to display error information returned by the
skylighting library.
Display a warning if the highlighting library throws an error.
Diffstat (limited to 'src/Text/Pandoc/Writers/LaTeX.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 578c7017f..7e1970d01 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -540,8 +540,11 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do "\\end{lstlisting}") $$ cr let highlightedCodeBlock = case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of - Nothing -> rawCodeBlock - Just h -> modify (\st -> st{ stHighlighting = True }) >> + Left msg -> do + unless (null msg) $ + report $ CouldNotHighlight msg + rawCodeBlock + Right h -> modify (\st -> st{ stHighlighting = True }) >> return (flush $ linkAnchor $$ text (T.unpack h)) case () of _ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes && @@ -958,8 +961,10 @@ inlineToLaTeX (Code (_,classes,_) str) = do return $ text $ "\\lstinline" ++ listingsopt ++ [chr] ++ str ++ [chr] highlightCode = do case highlight formatLaTeXInline ("",classes,[]) str of - Nothing -> rawCode - Just h -> modify (\st -> st{ stHighlighting = True }) >> + Left msg -> do + unless (null msg) $ report $ CouldNotHighlight msg + rawCode + Right h -> modify (\st -> st{ stHighlighting = True }) >> return (text (T.unpack h)) rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}")) $ stringToLaTeX CodeString str |