DEV Community

Stephanie Baltus
Stephanie Baltus

Posted on

3 3

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 💜.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs