I’m interested in adding code snippets with syntax highlighting to my Jekyll site. Obviously the following works fine,
```lang
some code here
```
where lang
is the language I want. However, I would like to load code from an external file, so that I can change it easily. This is simple enough to do with a little bit of Javascript and HTML, like this
<script>
fetch('url_here')
.then(response => {
return response.text();
})
.then(text => {
document.getElementById("demo").innerHTML = text;
})
</script>
<pre><code id="demo"></code></pre>
but the code comes out without syntax highlighting, presumably because Jekyll/Liquid does not evaluate the contents of <code>
. If I put this in a markdown codeblock or use {% highlight %}
, like so
```lang
<pre><code id="demo"></code></pre>
```
I literally get <pre><code id="demo"></code></pre>
, not what it evaluates to. Any ideas how I can achieve what I want?
Thanks!