#set html outputting as a string

1 messages · Page 1 of 1 (latest)

spice seal
#

I'm using set:html and it's outputting a string into the DOM, what am I doing wrong?

code:

<div set:html={formatCode(field.data.code)} />

output:

<div>
"<pre class="shiki"><code><span>&lt;div</span></code></pre>"
</div>
#

this is the function I'm using, basic Shiki configuration which returns a string

async function formatCode(code) {
  return shiki.getHighlighter({
    theme: 'nord',
  }).then(highlighter => {
    return highlighter.codeToHtml(code, { lang: 'html' })
  })
}
neat folio