Getting prism's command-line plugin working with Hugo

I’m trying to get prism’s command-line plugin working. I think using a shortcode is the correct way to do this, but I’m running into a strange problem. As far as I can tell, something somewhere is getting processed incorrectly. Here’s the shortcode I originally tried:

<pre class="language-nohighlight command-line" {{ with .Get "data-user" }}data-user="{{ . }}"{{ end }} {{ with .Get "data-host" }} data-host="{{ . }}"{{ end }} {{ with .Get "data-output" }} data-output="{{ . }}"{{ end }}>
    <code>
        {{ .Inner }}
    </code>
</pre>

And here’s how I’m using the shortcode:

{{< prism data-user="user" data-host="hostname" data-output="2" >}}
ls
foo bar baz
{{< /prism >}}

But that gets formatted all wrong: too many lines, and a space at the top (and apparently new users can only post one image).

And here’s where (in my opinion) things get really weird: I tried this:

`<pre class="language-nohighlight command-line" {{ with .Get "data-user" }}data-user="{{ . }}"{{ end }} {{ with .Get "data-host" }} data-host="{{ . }}"{{ end }} {{ with .Get "data-output" }} data-output="{{ . }}"{{ end }}> <code> {{ .Inner }} </code> </pre>`

Exactly the same as the original shortcode, but all on one line rather than several. That gets formatted differently: things line up a bit better, but there’s still extra lines (not as many, though!) and a space at the top.

Here’s my hypothesis: the shortcode is getting expanded to several lines of html, and prism is basing the number of lines on that html rather than the stuff inside the tags. Why? I have no idea.

So, can someone please tell me what the heck is going on—and how to fix it?

Newlines in Go templates are hard to manage properly.

You can try this syntax and see if it helps:

``
{{- with .Get “data-user” -}}


Which will remove newlines at both ends.

That didn’t appear to have any effect