Shortcode adds newline

I have a shortcode bg to highlight a word with a background color:

<span style="background-color: {{ .Get "color"  | safeCSS }};">{{ .Inner }}</span>

Now when I call it within markdown, e.g. with

This is an {{< bg color="red" >}}important phrase{{< /bg >}}, and then comes a comma.

then the output on the website looks like:

This is an important phrase , and then comes a comma.

The problem is the space in front of the comma. It comes because the shortcode call introduces newlines into the HTML.

How can I solve this? I’m grateful for any help!

Turns out there’s an interesting fix to this:

2 Likes

Thanks, that works!

1 Like

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