How can I use Prettify with Blogger/BlogSpot?

前端 未结 11 2094
轮回少年
轮回少年 2020-12-07 09:58

I\'m using blogger.com to host some texts on programming, and I\'d like to use Prettify (same as Stack Overflow) to nicely colour the code samples.

How do I ins

11条回答
  •  感动是毒
    2020-12-07 10:33

    Go to blogger theme section and click on edit HTML.. Then add the Google Prettify CDN to the head tag of the HTML.

    https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js'/>

    Then include a theme for code snippet below this script..I included Desert theme.

    
    

    For more themes, visit here.. Prettify themes

    When you create a post, change the edit mode from visual to HTML and go to the place where you are going to add the code snippet. Then include the code like this.

      
          
      
    

    You can change the code style by selecting relevant languages html, css, php, javascript... Here I used a html code snippet.

提交回复
热议问题