Sunday, May 28, 2017

highlight code on blogger with code-pretty

Mainly, there are two ways to highlight codes on blogger which are syntaxhighlighter and code-prettify. I tried code-prettify and installation tips are below.

1. config template

open the http configuration page("theme" > "edit html")


put the script tag below just above "<head>".
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

then push the save button.

2. write blog post

To write blog post, write like this. make sure you select "html" tab to edit post.
<pre class="prettyprint"><code class="language-python">
# code here
print ("hogehoge")
</code></pre>
shown like this.
# code here
print ("hogehoge")