git.iko.soy/typeable/pandoc
on master help sign in
Don't use tilde code blocks with braced attributes in gfm output.
f966295John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+9−9
@@ -381,13 +381,11 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str)
381 isEnabled Ext_literate_haskell opts =
381 isEnabled Ext_literate_haskell opts =
382 return $ prefixed "> " (text str) <> blankline
382 return $ prefixed "> " (text str) <> blankline
383blockToMarkdown opts (CodeBlock attribs str) = return $
383blockToMarkdown opts (CodeBlock attribs str) = return $
384− case attribs of
384+ case attribs == nullAttr of
385+ False | isEnabled Ext_backtick_code_blocks opts ->
386+ backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline
385− x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts ->
387+ | isEnabled Ext_fenced_code_blocks opts ->
386− tildes <> " " <> attrs <> cr <> text str <>
388+ tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline
387− cr <> tildes <> blankline
388− (_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts ->
389− backticks <> " " <> text cls <> cr <> text str <>
390− cr <> backticks <> blankline
391 _ -> nest (writerTabStop opts) (text str) <> blankline
389 _ -> nest (writerTabStop opts) (text str) <> blankline
392 where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of
390 where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of
393 [] -> "~~~~"
391 [] -> "~~~~"
@@ -396,8 +394,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
396 | otherwise -> replicate (n+1) '~'
394 | otherwise -> replicate (n+1) '~'
397 backticks = text "```"
395 backticks = text "```"
398 attrs = if isEnabled Ext_fenced_code_attributes opts
396 attrs = if isEnabled Ext_fenced_code_attributes opts
399− then nowrap $ attrsToMarkdown attribs
397+ then nowrap $ " " <> attrsToMarkdown attribs
398+ else case attribs of
399+ (_,[cls],_) -> " " <> text cls
400− else empty
400+ _ -> empty
401blockToMarkdown opts (BlockQuote blocks) = do
401blockToMarkdown opts (BlockQuote blocks) = do
402 st <- get
402 st <- get
403 -- if we're writing literate haskell, put a space before the bird tracks
403 -- if we're writing literate haskell, put a space before the bird tracks
tests/lhs-test.markdown+2−2
@@ -4,11 +4,11 @@ lhs test
4`unsplit` is an arrow that takes a pair of values and combines them to return
4`unsplit` is an arrow that takes a pair of values and combines them to return
5a single value:
5a single value:
6
6
7−~~~~ {.sourceCode .literate .haskell}
7+``` {.sourceCode .literate .haskell}
8unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
9unsplit = arr . uncurry
9unsplit = arr . uncurry
10 -- arr (\op (x,y) -> x `op` y)
10 -- arr (\op (x,y) -> x `op` y)
11−~~~~
11+```
12
12
13`(***)` combines two arrows into a new arrow by running the two arrows on a
13`(***)` combines two arrows into a new arrow by running the two arrows on a
14pair of values (one arrow on the first item of the pair and one arrow on the
14pair of values (one arrow on the first item of the pair and one arrow on the