Unexpected HTML escaping

This is inside of a shortcode:

<{{.Get 0}}>test</{{.Get 0}}>
<   {{.Get 0}}   >test</h3>
<    p           >test</p>
<p>test</p>

And this is the HTML code generated by it when using {{< test "h3">}}:

&lt;h3>test&lt;/h3>
&lt;   h3   >test</h3>
&lt;    p           >test</p>
<p>test</p>

Why is this happening? Why are the less than randomly escaped?

Why is it happening? Not sure, but I suspect there are security considerations; you are effectively using user input to generate HTML elements.

But this works just fine…

{{ printf "<%s>test</%s>" (.Get 0) (.Get 0) | safeHTML }}

I would guess the same thing. Also, browsers may try to “fix” mistakes as they run across them or will ignore things that they don’t understand. It would be good to compare the actual hugo output with what the dev console says