Make Prism.js Show Line Numbers by Default Using jQuery
January 13, 2019

Make Prism.js Show Line Numbers by Default Using jQuery

Well, this is going to be a short one.

Read this first if you haven't configured code highlighting yet for your Ghost Blog, and also make sure to add a reference to the Line Numbers plugin. First, make sure to read how to Add Syntax Highlighting to your Ghost Blog (with Prism.js). Then, plop the code below into your Blog Footer area (on the Code injection page in your admin panel):

<script>
    $("pre").addClass("line-numbers");
</script>

That's it!

The only catch might be if you don't have jQuery loaded before these lines, but that should be easy enough to sort out.

See also

Make Prism.js Show Line Numbers by Default Using jQuery
Share this