DEV Community

Stephanie Baltus
Stephanie Baltus

Posted on

Hugo.io - Multiline cells in a table

A problem

Building table in markdown is super easy and well-documented.

However, having a bit of formatting within it, like carriage return within a cell as below is not possible by default.

multiline-cell
Hugo uses Goldmark (a CommonMark implementation in Go) to process the markdown. Apparently it's extremely fast, with this implementation we choose to block any HTML processing d'HTML by default.

A solution

Once you know this, solving this is pretty straightforward.

You can customize plenty of Goldmark options in the configuration file (config.toml/yaml/json).
So what we want to do is autorising Goldmark to render HTML content :

[markup.goldmark]
    [markup.goldmark.renderer]
    unsafe = true 
Enter fullscreen mode Exit fullscreen mode

From now, within the table, we just need to add <br> tag as below :

|Adresse | Parking de La Poste<br> Le Bourg <br>97122 Baie-Mahault |
Enter fullscreen mode Exit fullscreen mode

That's it !

Free tips

If you don't want to bother with | when building tables, someone very nice has built a table generator.

We thank this person, from the bottom of our heart πŸ’œ.

Top comments (0)