Highlighting code / embedded code (Python)?


#1
  • Ghost version 2.7.0
  • Theme: Casper

I’m looking to include embedded Python code in my blog in the future. I want it to be color coded.
I tried this with markdown language, but it does sadly not color code:

```python

```

Another thing is, that I don’t want to have to do it manually. I just want to paste my code in some field, and then the field needs to process that and highlight it correctly.

I found Prism, does anyone have experience with it?

Any other suggestions are appreciated.

NOTE: Prism works with all languages, so you can actually use this with pretty much any common language!

EDIT: I have now implemented Prism into my Casper theme, and it works. You just add the css and js files to the respective pre-existing folders in the Casper theme. Then you just reference it in default.hbs.

Below {{!-- Styles'n'Scripts --}} paste this:
<link rel="stylesheet" type="text/css" href="{{asset "css/prism.css"}}" />

Below {{ghost_foot}} paste this:
<script type="text/javascript" src="{{asset "js/prism.js"}}"></script>

And then it looks like this (magic):


#2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.