git.iko.soy/typeable/pandoc
on master help sign in
Don't use tilde code blocks with braced attributes in gfm output.

A consequence of this change is that the backtick form will be preferred in general if both are enabled. I think that is good, as it is much more widespread than the tilde form. Closes #1084.

commitf9662957704ebfe83d7764dd64151d37c476c0b0 authorJohn MacFarlane <fiddlosopher@gmail.com> dateMon 9 Dec 2013, 20:31 (13 years ago) parent571480e
2 files changed+11−11
src/Text/Pandoc/Writers/Markdown.hs+9−9 tests/lhs-test.markdown+2−2
src/Text/Pandoc/Writers/Markdown.hs+9−9
@@ -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
tests/lhs-test.markdown+2−2
@@ -4,11 +4,11 @@ lhs test
44`unsplit` is an arrow that takes a pair of values and combines them to return
55a single value:
66
7−~~~~ {.sourceCode .literate .haskell}
7+``` {.sourceCode .literate .haskell}
88unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
99unsplit = arr . uncurry
1010 -- arr (\op (x,y) -> x `op` y)
11−~~~~
11+```
1212
1313`(***)` combines two arrows into a new arrow by running the two arrows on a
1414pair of values (one arrow on the first item of the pair and one arrow on the