そこで、Fazibear氏が公開している、Blogger Syntax Highlighter Widget に、PIC Assembler を追加してみました。
1.Fazibear氏のページから、widget を導入します。
2.[レイアウト]-[ページの要素]から、そのwidgetの編集を選びます。
3.変更箇所は2カ所です。まず1ヶ所目は、
.dp-highlighter .preprocessor { color: gray; background-color: inherit; }
</style>
の部分を、
.dp-highlighter .preprocessor { color: gray; background-color: inherit; }
.dp-highlighter .pasm_builtins { color: #069; font-weight: bold; background-color: inherit; }
</style>
と、02行目を加えます。これはPIC Assembler の疑似命令の色を決定しています。
もう1ヶ所は、
dp.sh.Brushes.Delphi.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Delphi.Aliases=['delphi','pascal'];
dp.sh.Brushes.Python=function()
の2行の間に、
dp.sh.Brushes.Delphi.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Delphi.Aliases=['delphi','pascal'];
dp.sh.Brushes.Pasm=function()
{var keywords='addwf andwf clrf clrw comf decf decfsz incfincfsz iorwf movf movwf '+'nop rlf rrf subwf swapf xorwf bcf bsf btfsc btfss addlw andlw '+'call clrwdt goto iorlw movlw retfie retlw return sleep sublw '+'xorlw movfw';
var builtins='__badram bankisel banksel cblock '+'endc code __config constant da data '+'db de #define #undefine dt dw end equ '+'error errorlevel exitm expand noexpand extern '+'fill global idata __idlocs #if #else #endif #ifndef '+'include list nolist local macro endm __maxram messg org '+'page pagesel processor radix res set space title subtitle '+'udata udata_acs udata_ovr udata_shr variable while endw';
this.regexList=[{regex:new RegExp('\;.*$','gm'),css:'comment'},{regex:dp.sh.RegexLib.DoubleQuotedString,css:'string'},{regex:dp.sh.RegexLib.SingleQuotedString,css:'string'},{regex:new RegExp(this.GetKeywords(builtins),'gm'),css:'pasm_builtins'},{regex:new RegExp('^\\s*#.*','gm'),css:'preprocessor'},{regex:new RegExp(this.GetKeywords(keywords),'gm'),css:'keyword'}];this.CssClass='dp-pasm';}
dp.sh.Brushes.Pasm.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Pasm.Aliases=['asm','pasm'];
dp.sh.Brushes.Python=function()
と、02行~06行を加えます。ここでPIC Assemblerの命令と疑似命令、コメントや文字列の色をブラシしています。
5.保存します。
これで対応されます。
投稿する場合には、ソースコードを、
<pre name="code" class="pasm"> ・・・・・ </pre>
で囲んでください。
元々のWidgetに加える形を取っているので、次のように、他のコードに対してもこのWidgetを使うことが出来ます。
Pythonの場合:
#!/usr/bin/env python
def hello():
print "Hello World!"
hello()
PIC Assemblerの場合:
;テスト
list P=12F675
include P12F675.INC
org 0 ;RESET VECTOR
goto MAIN
org 4 ;INTERRUPT VECTOR
goto MAIN
org 5
MAIN
movlw b'10010111'
btfss GPIO,GP5
goto MAIN
sleep
参考にしたページ:
Fazibear
クリボウの Blogger Tips
Yet Another Coding Blog
Damien Learns Perl
0 件のコメント:
コメントを投稿