I have been using Ghost pro for a few years now as my blogging platform and I love it. However, its lack of code formatting (syntax highlighting) has made it difficult to use the default theme (Casper) to display source code. I love the Casper theme, so I decided to work out how to add the Prism syntax highlighting engine to my blog (without creating a custom theme).
To do this, simply log into your control panel for Ghost and click on the
Code Injection
menu option. Then, simply paste the following HTML in the
Footer section:
You can find additional plugins and languages listed on the Prism CDN. You can also find alternative themes to use. I am using the “Coy” theme for the code on my blog.
Once you’ve added a link to the Prism.js JavaScript files, adding code is as easy as using the specific code markup.
```csharp
public string SomeProperty { get; set; }
```
This will display as
public string SomeProperty { get; set; }
You can also add line numbers to your code by doing this:
public void AddTwoIntegers(int param1, int param2)
{
var result = param1 + param2;
Console.WriteLine($"{param1} + {param2} = {result}");
}
`
The result will look like this:
public void AddTwoIntegers(int param1, int param2)
{
var result = param1 + param2;
Console.WriteLine($"{param1} + {param2} = {result}");
}