google了一下找了一個覺得好設定的外掛SyntaxHighlighter,只是設定完後沒多久心血來潮改個主題樣式,改完後馬上傻眼,原來會蓋掉原先加上去的code,不過還好剛剛說了外掛還蠻好設定,一下就復原了,不過怕忘記怎麼設定,還是筆記一下免得下次又做了蠢事還要再google一次,以下為設定方式
請注意,使用此外掛在連結Blogger不能使用https,外掛會失效,以及編輯時無法預覽,建議最後再加上程式碼
以下為加入外掛步驟:
1.進入Blogger後台->主題->編輯HTML
在<head></head>之間加入以下code
<!-- Include required JS files -->
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<!--
At least one brush, here we choose JS. You need to include a brush for every
language you want to highlight
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
-->
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<!-- Include *at least* the core style and default theme -->
<link href="https://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="https://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<!-- Finally, to actually run the highlighter, you need to include this JS on your page -->
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
另外要顯示不同的script要加入對應的js
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
把shBrushJScript.js改成自己需要的,如果你的Blogger需要多個script就新增多個上去
以下為網站上顯示的對照表
brushes清單
2.使用HTML編輯文章加入以下Code
<pre class="brush: script名稱">
code....
</pre>
加入就會出現以下結果了
if(a==1) { b=a; }
沒有留言:
張貼留言