git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Use longer backtick fences if needed.
361167dJohn MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+5−1
@@ -392,7 +392,11 @@ blockToMarkdown opts (CodeBlock attribs str) = return $
392 xs -> case maximum $ map length xs of
392 xs -> case maximum $ map length xs of
393 n | n < 3 -> "~~~~"
393 n | n < 3 -> "~~~~"
394 | otherwise -> replicate (n+1) '~'
394 | otherwise -> replicate (n+1) '~'
395− backticks = text "```"
395+ backticks = text $ case [ln | ln <- lines str, all (=='`') ln] of
396+ [] -> "```"
397+ xs -> case maximum $ map length xs of
398+ n | n < 3 -> "```"
399+ | otherwise -> replicate (n+1) '`'
396 attrs = if isEnabled Ext_fenced_code_attributes opts
400 attrs = if isEnabled Ext_fenced_code_attributes opts
397 then nowrap $ " " <> attrsToMarkdown attribs
401 then nowrap $ " " <> attrsToMarkdown attribs
398 else case attribs of
402 else case attribs of