The 0.60+ move to Goldmark for Markdown rendering has caused some issues with the formatting that I use in a handful of Hugo blog sites. In those sites I typically have blocks of terminal commands that I put into tables, but to improve readability, and copy/paste capability, I generally put multiple commands into a single cell and separate them using <br/>
tags. Well, Goldmark won’t render these as line-breaks, they just disappear, so I get one long continuous command per cell.
The markdown I use typically looks something like this example:
| Host Commands |
| --- |
| cd ~/GitHub/dg-isle <br/> git checkout master <br/> docker-compose up -d <br/> docker logs -f isle-apache-dg |
With Goldmark in play I tried changing that syntax to use double spaces and CRLF at the end of each command but that didn’t help, presumably because the text is already inside a table cell? I also tried a number of other tricks, like ending each command with a slash or back-slash, and those also did not work. In most cases these changes caused each command to appear inside it’s own cell…not quite what I was aiming for.
So, ultimately I put an entry in my config.toml to force markup to render using the old BlackFriday engine, just to suppress this change in behavior. However, I’d prefer to apply a proper fix going forward, one that doesn’t require a wholesale override of Goldmark.
My question is: How can I code hard line-breaks within a table cell when using the Goldmark engine? Or, is there a Goldmark setting that I can apply to force rendering of my <br/>
marks inside table cells? Or, alternatively, is there a better way to present commands like this, one that doesn’t require any overrides or setting changes? I’ll consider introducing a shortcode, but would rather not do so unless it’s absolutely necessary.
Thanks in advance for any suggestions.