Newline in markdown table

I’m trying to use the <br /> command to get a newline inside one markdown cell:

|     |     |
| --: | --- |
| blah | blah <br /> blah <br /> blah |

However, it doesn’t work when I preview the page using hugo server: all supposed newlines appear on the same line. Any suggestion?

To let raw HTML markup rendered, set unsafe: true in your config:

markup:
  goldmark:
   renderer:
     unsafe: true

The fact that this parameter is named “unsafe” means that it’s bad and there are ways to “do it properly”.

A newline in Markdown is created by “2 spaces at the end of the line and a single newline”.

sample text__
sample text

where the _ are spaces.

Now, many text editors remove spaces at the end of the line. Which is bad for markdown files :wink: Some text editors allow you to remove the “remove trailing whitespace on lines” feature for markdown files which is (IMHO) an indicator of a “good” editor for your markdown use.

What about a newline inside a table cell? There’s no “end of the line” in this case, or does the rule apply to “end of cell text”, too?

https://github.github.com/gfm/#tables-extension-

which is what Goldmark uses says:

Block-level elements cannot be inserted in a table.

A hard break is a block-level element and ergo cannot be added (as Markdown) to a table.

If you wanted to avoid the unsafe you would need to create a shortcode.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.