add C++ code to blogger

我使用的是google code prettify(似乎用電腦才能看到美化?)

1.打開版面配置

2.找到footer-1,點選「新增小工具」




3.選取「HTML/JavaScript」


4.在內容加入以下程式碼
5.最後,在攥寫文章時加入以下程式碼
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=desert"></script>

<style>
li.L0, li.L1, li.L2, li.L3,
li.L5, li.L6, li.L7, li.L8 {
  list-style-type: decimal !important;
}

</style>
上面的部分是導入google code prettify,並且使用desert樣式(其他樣式
下半部是讓code顯示行數的程式碼
註:不知道怎麼夾可以滾動的code顯示窗,程式碼過長過長不知如何解

5.最後,在攥寫文章時加入以下程式碼
<pre class="prettyprint lang-html linenums">
..yourcode
</pre>
或是
<pre class="prettyprint linenums"><code class="language-cpp">
...
</code></pre>
language後面接你的程式碼類型

參考 https://github.com/google/code-prettify

留言