@@ -48,7 +48,7 @@ highlight :: ([FormatOption] -> String -> [SourceLine] -> a) -- ^ Formatter
4848 -> Bool -- ^ True if inline
4949 -> Attr -- ^ Attributes of the Code or CodeBlock
5050 -> String -- ^ Raw contents of the Code or CodeBlock
51− -> Either String a -- ^ An error or the formatted result
51+ -> Maybe a -- ^ Maybe the formatted result
5252highlight formatter inline (_, classes, keyvals) rawCode =
5353 let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of
5454 ((n,_):_) -> n
@@ -61,25 +61,25 @@ highlight formatter inline (_, classes, keyvals) rawCode =
6161 addBirdTracks = "literate" `elem` classes
6262 lcLanguages = map (map toLower) languages
6363 in case find (\c -> (map toLower c) `elem` lcLanguages) classes of
64− Nothing -> Left "Unknown or unsupported language"
65− Just language -> case highlightAs language rawCode of
66− Left err -> Left err
67− Right hl -> Right $ formatter fmtOpts language
68− $ if addBirdTracks
69− then map ((OtherTok,"> "):) hl
70− else hl
64+ Nothing -> Nothing
65+ Just language -> Just
66+ $ formatter fmtOpts language .
67+ (if addBirdTracks
68+ then map ((OtherTok,"> "):)
69+ else id)
70+ $ highlightAs language rawCode
7171
7272highlightHtml :: Bool -- ^ True if inline HTML
7373 -> Attr -- ^ Attributes of the Code or CodeBlock
7474 -> String -- ^ Raw contents of the Code or CodeBlock
75− -> Either String Html -- ^ An error or the formatted Html
75+ -> Maybe Html -- ^ Maybe formatted Html
7676highlightHtml inline attr@(id',_,_) = fmap addId . highlight formatAsHtml inline attr
7777 where addId = if null id' then id else (! A.id (toValue id'))
7878
7979highlightLaTeX :: Bool -- ^ True if inline
8080 -> Attr -- ^ Attributes of the Code or CodeBlock
8181 -> String -- ^ Raw contents of the Code or CodeBlock
82− -> Either String String -- ^ An error or the formatted LaTeX string
82+ -> Maybe String -- ^ Maybe formatted LaTeX
8383highlightLaTeX = highlight formatAsLaTeX
8484
8585#else
@@ -92,9 +92,9 @@ languages = []
9292languagesByExtension :: String -> [String]
9393languagesByExtension _ = []
9494
95−highlightHtml :: Bool -> Attr -> String -> Either String Html
95+highlightHtml :: Bool -> Attr -> String -> Maybe Html
9696highlightHtml _ _ _ = Left "Pandoc was not compiled with support for highlighting"
9797
98−highlightLaTeX :: Bool -> Attr -> String -> Either String String
98+highlightLaTeX :: Bool -> Attr -> String -> Maybe String
9999highlightLaTeX _ _ _ = Left "Pandoc was not compiled with support for highlighting"
100100#endif