diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-18 12:33:11 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2011-12-18 12:33:11 -0800 |
commit | 1a22e75352c05f345bb8a6ed02f14b9749355143 (patch) | |
tree | c1be1bcde72e4f43e0a73b6c61e9235299965b36 /src/Text/Pandoc | |
parent | f0e0e1e5d4f80140b7e965f1db1af3528d0833da (diff) | |
download | pandoc-1a22e75352c05f345bb8a6ed02f14b9749355143.tar.gz |
HTML writer: Retain ID attribute in highlighted code blocks.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Highlighting.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs index efa4fa20e..547ebc223 100644 --- a/src/Text/Pandoc/Highlighting.hs +++ b/src/Text/Pandoc/Highlighting.hs @@ -36,6 +36,7 @@ import Text.Highlighting.Kate ( languages, highlightAs, formatAsHtml, FormatOpti import Data.List (find) import Data.Maybe (fromMaybe) import Data.Char (toLower) +import qualified Text.Blaze.Html5.Attributes as A highlightHtml :: Bool -- ^ True if inline HTML -> Attr -- ^ Attributes of the Code or CodeBlock @@ -52,12 +53,14 @@ highlightHtml inline (id', classes, keyvals) rawCode = Just _ -> [OptNumberLines] addBirdTracks = "literate" `elem` classes lcLanguages = map (map toLower) languages + addId = if null id' then id else (! A.id (toValue id')) in case find (\c -> (map toLower c) `elem` lcLanguages) classes of Nothing -> Left "Unknown or unsupported language" Just language -> case highlightAs language rawCode of Left err -> Left err - Right hl -> Right $ formatAsHtml fmtOpts language $ - if addBirdTracks + Right hl -> Right $ addId + $ formatAsHtml fmtOpts language + $ if addBirdTracks then map (("ot","> "):) hl else hl |