I want to host some API documentation example code snippets, where the snippets live in different files and are include
d into a Jekyll page. I'm using Jekyll include
tag (https://jekyllrb.com/docs/includes/).
e.g. given this input:
The `br` tag is for line breaks. Example:
<pre>
{% include code-snippet.html %}
</pre>
And code-snippet.html
might be like:
<!doctype html>
First line<br>
Second line
I get this output, which has the browser interpreting the tags as HTML:
The `<br>` tag is for line breaks. Example:
<pre>
<!doctype html>
First line<br>
Second line
</pre>
But I'd rather get this output, with the browser interpreting the tags as text:
The `<br>` tag is for line breaks. Example:
<pre>
<!doctype html>
First line<br>
Second line
</pre>
Is there a way to achive this in Jekyll? Is there something like {% include code-snippet.html | htmlEscape %}
? I imagine I could fix this with a Ruby plugin (after all, the include
tag is just Ruby), but I'd like to avoid writing a plugin if possible.