From 4f8df0ebe205a90139c4901ac7a7cee613564ebf Mon Sep 17 00:00:00 2001 From: Ivan Lazar Miljenovic Date: Thu, 5 Oct 2017 14:41:40 +1100 Subject: [PATCH] Make sure code blocks are indented in markdown documentation This relies on the behaviour of pandoc, and as such may not apply to other Markdown renderers. Before this change, you would have something like: > - Example: `application/json` > > ```javascript > "HELLO, HASKELLER" > ``` When converting this to HTML, PDF, etc. the code block is _not_ contained within the bullet point. With this change, the generated markdown looks like: > - Example: `application/json` > > ```javascript > "HELLO, HASKELLER" > ``` With pandoc at least, this effectively indents the entire code block to be under the bullet point, which is the intended effect. Note that the code itself is _not_ indented (which might break other Markdown renderers) as to do so would require splitting on newlines, which may have unintended consequences when dealing with generated values (may contain `\r\n`, etc.). --- servant-docs/src/Servant/Docs/Internal.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index 7bf3481f..bd43bba8 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -653,11 +653,12 @@ markdown api = unlines $ ("text", "css") -> "css" (_, _) -> "" + contentStr mime_type body = "" : - "```" <> markdownForType mime_type : + " ```" <> markdownForType mime_type : cs body : - "```" : + " ```" : "" : []