@@ -37,7 +37,7 @@ import Text.Pandoc.Readers.TeXMath
3737import Text.Pandoc.Highlighting ( highlightHtml, defaultHighlightingCss )
3838import Numeric ( showHex )
3939import Data.Char ( ord, toLower )
40−import Data.List ( isPrefixOf, intercalate )
40+import Data.List ( isPrefixOf )
4141import Data.Maybe ( catMaybes )
4242import qualified Data.Set as S
4343import Control.Monad.State
@@ -248,21 +248,20 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
248248blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
249249blockToHtml _ (RawHtml str) = return $ primHtml str
250250blockToHtml _ (HorizontalRule) = return $ hr
251−blockToHtml opts (CodeBlock (_,classes,_) rawCode) | "haskell" `elem` classes &&
252− "literate" `elem` classes &&
253− writerLiterateHaskell opts =
254− let classes' = map (\c -> if c == "haskell" then "literatehaskell" else c) classes
255− in blockToHtml opts $ CodeBlock ("",classes',[]) $ intercalate "\n" $ map ("> " ++) $ lines rawCode
256−blockToHtml _ (CodeBlock attr@(_,classes,_) rawCode) = do
257− case highlightHtml attr rawCode of
251+blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
252+ let classes' = if writerLiterateHaskell opts
253+ then classes
254+ else filter (/= "literate") classes
255+ case highlightHtml (id',classes',keyvals) rawCode of
258256 Left _ -> -- change leading newlines into <br /> tags, because some
259257 -- browsers ignore leading newlines in pre blocks
260258 let (leadingBreaks, rawCode') = span (=='\n') rawCode
261− in return $ pre ! (if null classes
262− then []
263− else [theclass $ unwords classes]) $ thecode <<
264− (replicate (length leadingBreaks) br +++
265− [stringToHtml $ rawCode' ++ "\n"])
259+ attrs = [theclass (unwords classes') | not (null classes')] ++
260+ [identifier id' | not (null id')] ++
261+ map (\(x,y) -> strAttr x y) keyvals
262+ in return $ pre ! attrs $ thecode <<
263+ (replicate (length leadingBreaks) br +++
264+ [stringToHtml $ rawCode' ++ "\n"])
266265 Right h -> addToCSS defaultHighlightingCss >> return h
267266blockToHtml opts (BlockQuote blocks) =
268267 -- in S5, treat list in blockquote specially