Markdown writer: Use longer backtick fences if needed.
If the content contains a backtick fence and there are attributes, make sure longer fences are used to delimit the code. Note: This works well in pandoc, but github markdown is more limited, and will interpret the first string of three or more backticks as ending the code block. Closes #1206.
This commit is contained in:
parent
69a7c9f634
commit
361167deff
1 changed files with 5 additions and 1 deletions
|
@ -392,7 +392,11 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
|
|||
xs -> case maximum $ map length xs of
|
||||
n | n < 3 -> "~~~~"
|
||||
| otherwise -> replicate (n+1) '~'
|
||||
backticks = text "```"
|
||||
backticks = text $ case [ln | ln <- lines str, all (=='`') ln] of
|
||||
[] -> "```"
|
||||
xs -> case maximum $ map length xs of
|
||||
n | n < 3 -> "```"
|
||||
| otherwise -> replicate (n+1) '`'
|
||||
attrs = if isEnabled Ext_fenced_code_attributes opts
|
||||
then nowrap $ " " <> attrsToMarkdown attribs
|
||||
else case attribs of
|
||||
|
|
Loading…
Reference in a new issue