Ghost Local Install Highlight.js make code highlight

Source: Internet
Author: User

For the program Ape to write a blog, this code highlighting is the minimum requirement. But ghost itself does not support highlighting code.

But can be achieved through the extension, it is highlight.js--attached to the official site, read the Ere page introduction, really very powerful, now say how to install, very easy.

Download Highlight.js

Already includes a very much supported highlighting language, assuming that you do not find the language you want, you can continue to check the following. Finally, click Download below.

Unzip the installation Highlight.js

Unzip the resource directory below the highlight.js to ghost Local theme directory. I am here:

Installing Highlight.js

Open the Default.hbs file in the theme directory with a text editor for editing:

Find {{! Styles ' n ' Scripts}}, join below:

<link rel="stylesheet" type="text/css" href="{{asset "/highlight/styles/hybrid.css"}}" />

The hybrid.css here is the code theme you want to use. Here I use the hybrid.css,, personal preferences. You can also select other theme styles under the Styles directory. You can go to this site to preview the various styles of code theme, choose your favorite.

Find {{! The main JavaScript file for Casper}}, join below:

 <script  type  = "text/ JavaScript " src  ="    {{asset  /highlight/ Highlight.pack.js "}}  "     </script   <script  type  = "Text/javascript" ;   </script ;    
How to use code highlighting

When Ghost comes with the Markdown editor. Follow the following format, for example:

<pre><code class="python">...</code></pre>

Python can be replaced by other languages.

Ok. Now you can experience the feeling of code highlighting! Effects such as the following, this is a Python code:

Ghost Local Install Highlight.js make code highlight

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.