How to post code snippet and run it

March 30, 2020

Highlight the code

Jekyll supplys a tag called highlight. It can accept some parameters - what's the code language and whether show lines numbers. More info

For example, this code

1{% highlight html linenos %}
2 <button>do alert</button>
3 <script>
4 document.querySelector('button').addEventListener('click', () => {
5 alert('clicked');
6 })
7 </script>
8{% endhighlight %}

Will render

1<button>do alert</button>
2<script>
3 document.querySelector('button').addEventListener('click', () => {
4 alert('clicked');
5 })
6</script>