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.).
This commit is contained in:
Ivan Lazar Miljenovic 2017-10-05 14:41:40 +11:00
parent 061bf7a5b1
commit 4f8df0ebe2

View file

@ -653,11 +653,12 @@ markdown api = unlines $
("text", "css") -> "css" ("text", "css") -> "css"
(_, _) -> "" (_, _) -> ""
contentStr mime_type body = contentStr mime_type body =
"" : "" :
"```" <> markdownForType mime_type : " ```" <> markdownForType mime_type :
cs body : cs body :
"```" : " ```" :
"" : "" :
[] []