@@ -48,7 +48,7 @@ highlight :: ([FormatOption] -> String -> [SourceLine] -> a) -- ^ Formatter
48 -> Bool -- ^ True if inline
48 -> Bool -- ^ True if inline
49 -> Attr -- ^ Attributes of the Code or CodeBlock
49 -> Attr -- ^ Attributes of the Code or CodeBlock
50 -> String -- ^ Raw contents of the Code or CodeBlock
50 -> 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
52highlight formatter inline (_, classes, keyvals) rawCode =
52highlight formatter inline (_, classes, keyvals) rawCode =
53 let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of
53 let firstNum = case reads (fromMaybe "1" $ lookup "startFrom" keyvals) of
54 ((n,_):_) -> n
54 ((n,_):_) -> n
@@ -61,25 +61,25 @@ highlight formatter inline (_, classes, keyvals) rawCode =
61 addBirdTracks = "literate" `elem` classes
61 addBirdTracks = "literate" `elem` classes
62 lcLanguages = map (map toLower) languages
62 lcLanguages = map (map toLower) languages
63 in case find (\c -> (map toLower c) `elem` lcLanguages) classes of
63 in case find (\c -> (map toLower c) `elem` lcLanguages) classes of
64− Nothing -> Left "Unknown or unsupported language"
64+ Nothing -> Nothing
65− Just language -> case highlightAs language rawCode of
65+ Just language -> Just
67− Right hl -> Right $ formatter fmtOpts language
66+ $ formatter fmtOpts language .
68− $ if addBirdTracks
67+ (if addBirdTracks
69− then map ((OtherTok,"> "):) hl
68+ then map ((OtherTok,"> "):)
70+ $ highlightAs language rawCode
72highlightHtml :: Bool -- ^ True if inline HTML
72highlightHtml :: Bool -- ^ True if inline HTML
73 -> Attr -- ^ Attributes of the Code or CodeBlock
73 -> Attr -- ^ Attributes of the Code or CodeBlock
74 -> String -- ^ Raw contents of the Code or CodeBlock
74 -> String -- ^ Raw contents of the Code or CodeBlock
75− -> Either String Html -- ^ An error or the formatted Html
75+ -> Maybe Html -- ^ Maybe formatted Html
76highlightHtml inline attr@(id',_,_) = fmap addId . highlight formatAsHtml inline attr
76highlightHtml inline attr@(id',_,_) = fmap addId . highlight formatAsHtml inline attr
77 where addId = if null id' then id else (! A.id (toValue id'))
77 where addId = if null id' then id else (! A.id (toValue id'))
79highlightLaTeX :: Bool -- ^ True if inline
79highlightLaTeX :: Bool -- ^ True if inline
80 -> Attr -- ^ Attributes of the Code or CodeBlock
80 -> Attr -- ^ Attributes of the Code or CodeBlock
81 -> String -- ^ Raw contents of the Code or CodeBlock
81 -> 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
83highlightLaTeX = highlight formatAsLaTeX
83highlightLaTeX = highlight formatAsLaTeX
@@ -92,9 +92,9 @@ languages = []
92languagesByExtension :: String -> [String]
92languagesByExtension :: String -> [String]
93languagesByExtension _ = []
93languagesByExtension _ = []
95−highlightHtml :: Bool -> Attr -> String -> Either String Html
95+highlightHtml :: Bool -> Attr -> String -> Maybe Html
96highlightHtml _ _ _ = Left "Pandoc was not compiled with support for highlighting"
96highlightHtml _ _ _ = Left "Pandoc was not compiled with support for highlighting"
98−highlightLaTeX :: Bool -> Attr -> String -> Either String String
98+highlightLaTeX :: Bool -> Attr -> String -> Maybe String
99highlightLaTeX _ _ _ = Left "Pandoc was not compiled with support for highlighting"
99highlightLaTeX _ _ _ = Left "Pandoc was not compiled with support for highlighting"