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.
This commit is contained in:
John MacFarlane 2013-12-09 20:31:47 -08:00
parent 571480eb4a
commit f966295770
2 changed files with 11 additions and 11 deletions

View file

@ -381,13 +381,11 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str)
isEnabled Ext_literate_haskell opts =
return $ prefixed "> " (text str) <> blankline
blockToMarkdown opts (CodeBlock attribs str) = return $
case attribs of
x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts ->
tildes <> " " <> attrs <> cr <> text str <>
cr <> tildes <> blankline
(_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts ->
backticks <> " " <> text cls <> cr <> text str <>
cr <> backticks <> blankline
case attribs == nullAttr of
False | isEnabled Ext_backtick_code_blocks opts ->
backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline
| isEnabled Ext_fenced_code_blocks opts ->
tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline
_ -> nest (writerTabStop opts) (text str) <> blankline
where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of
[] -> "~~~~"
@ -396,8 +394,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
| otherwise -> replicate (n+1) '~'
backticks = text "```"
attrs = if isEnabled Ext_fenced_code_attributes opts
then nowrap $ attrsToMarkdown attribs
else empty
then nowrap $ " " <> attrsToMarkdown attribs
else case attribs of
(_,[cls],_) -> " " <> text cls
_ -> empty
blockToMarkdown opts (BlockQuote blocks) = do
st <- get
-- if we're writing literate haskell, put a space before the bird tracks

View file

@ -4,11 +4,11 @@ lhs test
`unsplit` is an arrow that takes a pair of values and combines them to return
a single value:
~~~~ {.sourceCode .literate .haskell}
``` {.sourceCode .literate .haskell}
unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
unsplit = arr . uncurry
-- arr (\op (x,y) -> x `op` y)
~~~~
```
`(***)` combines two arrows into a new arrow by running the two arrows on a
pair of values (one arrow on the first item of the pair and one arrow on the