@@ -381,13 +381,11 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str)
381381 isEnabled Ext_literate_haskell opts =
382382 return $ prefixed "> " (text str) <> blankline
383383blockToMarkdown opts (CodeBlock attribs str) = return $
384− case attribs of
385− x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts ->
386− tildes <> " " <> attrs <> cr <> text str <>
387− cr <> tildes <> blankline
388− (_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts ->
389− backticks <> " " <> text cls <> cr <> text str <>
390− cr <> backticks <> blankline
384+ case attribs == nullAttr of
385+ False | isEnabled Ext_backtick_code_blocks opts ->
386+ backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline
387+ | isEnabled Ext_fenced_code_blocks opts ->
388+ tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline
391389 _ -> nest (writerTabStop opts) (text str) <> blankline
392390 where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of
393391 [] -> "~~~~"
@@ -396,8 +394,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
396394 | otherwise -> replicate (n+1) '~'
397395 backticks = text "```"
398396 attrs = if isEnabled Ext_fenced_code_attributes opts
399− then nowrap $ attrsToMarkdown attribs
400− else empty
397+ then nowrap $ " " <> attrsToMarkdown attribs
398+ else case attribs of
399+ (_,[cls],_) -> " " <> text cls
400+ _ -> empty
401401blockToMarkdown opts (BlockQuote blocks) = do
402402 st <- get
403403 -- if we're writing literate haskell, put a space before the bird tracks