$(document).ready(function() {
function path()
{
var args = arguments,result = [];
for(var i = 0; i < args.length; i++)
result.push(args[i].replace('@', '<$BaseUrl$>/syntaxhighlighter/scripts/'));
return result
};
SyntaxHighlighter.autoloader.apply(null, path(
'css @shBrushCss.js',
'java @shBrushJava.js',
'js jscript javascript @shBrushJScript.js',
'php @shBrushPhp.js',
'text plain @shBrushPlain.js',
'sql @shBrushSql.js',
'xml xhtml xslt html @shBrushXml.js'
));
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
}); ファイルのダウンロード
SyntaxHighlgihterからダウンロードします。メニューのDonwloadsを選んで => 本文中のClick Here to downloadをクリック
ファイルの解凍
ファイルを入手したら、zipファイルなんで解凍します。解凍したらこんな感じのファイル構成になっているかと・・・。
使うのは、scripts内にあるJavaScriptファイルとstylesのCSSファイルだけです。
ファイルのアップロード
適当にフォルダー作ったりして、ファイルをアップロードします。ブログの管理画面で画像/ファイル > ファイル管理を選択。
JavaScriptファイルのアップロード
解凍したフォルダーのscriptsにあるファイルを全部アップロードすれば間違いありません。が、面倒な場合は、必須のファイルだけをアップロードします。
- shCore.js
- shAutoLoader.js
CSSファイルのアップロード
CSSファイルは、解凍したフォルダーのStylesにあります。ここもいっぱいファイルがあるんですけど、必須なのは、下記の2ファイルです。
- shCore.css
- shThemeDefault.css
他のファイルは何なのかと言うと、きっと表示のスタイルを変えたい場合に使用するのかと。試してないけど、察するに、2ファイルの組み合わせでできてるみたいなので、shCore.cssとshThemeDefault.cssの変わりに
- shCoreEclipse.css
- shThemeEclipse.css
なんて組み合わせでファイルをロードしてあげれば、違ったスタイルになるんじゃないのかと思います。たぶん。
アップロードしたファイルをブログに組み込む
ブログ設定→デザイン / ブログパーツ設定 PC → カスタマイズ →トップページ
HTMLのhead内でアップロードしたJavaScriptとCSSファイルを読み込んで、スクリプトを呼び出してます。
<!-- Syntax Highlighterのファイルを読み込む --> <link href="<$BaseUrl$>/syntaxhighlighter/css/shCore.css" rel="stylesheet" type="text/css" /> <link href="<$BaseUrl$>/syntaxhighlighter/css/shThemeBlog.css" rel="stylesheet" type="text/css" /> <script src="<$BaseUrl$>/syntaxhighlighter/scripts/shCore.js" type="text/javascript"></script> <script src="<$BaseUrl$>/syntaxhighlighter/scripts/shAutoloader.js" type="text/javascript"></script>
<!-- Syntax Highlighterのそれぞれの言語ファイルを呼び出すスクリプト -->
<script type="text/javascript"> $(document).ready(function() { function path() { var args = arguments,result = []; for(var i = 0; i < args.length; i++) result.push(args[i].replace('@', '<$BaseUrl$>/syntaxhighlighter/scripts/')); return result }; SyntaxHighlighter.autoloader.apply(null, path( 'css @shBrushCss.js', 'java @shBrushJava.js', 'js jscript javascript @shBrushJScript.js', 'php @shBrushPhp.js', 'text plain @shBrushPlain.js', 'sql @shBrushSql.js', 'xml xhtml xslt html @shBrushXml.js' )); SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); }); </script> </head>
ファイルの読み込み
<!-- Syntax Highlighterのファイルを読み込む --> <link href="<$BaseUrl$>/syntaxhighlighter/css/shCore.css" rel="stylesheet" type="text/css" /> <link href="<$BaseUrl$>/syntaxhighlighter/css/shThemeBlog.css" rel="stylesheet" type="text/css" /> <script src="<$BaseUrl$>/syntaxhighlighter/scripts/shCore.js" type="text/javascript"></script> <script src="<$BaseUrl$>/syntaxhighlighter/scripts/shAutoloader.js" type="text/javascript"></script>
このブログでは、syntaxhighlighter/scriptsにJavaScriptのファイルを。syntaxhighlighter/css/にCSSのファイルをアップロードしてます。LiveDoorブログを触ったこと無いのでアレなんですけど、<$BaseUrl$>は、自身のブログのURLに変えてくれる魔法のフレーズなのかと。
言語ファイルの読み込み<script type="text/javascript">
$(document).ready(function() {
function path()
{
var args = arguments,result = [];
for(var i = 0; i < args.length; i++)
result.push(args[i].replace('@', '<$BaseUrl$>/syntaxhighlighter/scripts/'));
return result
};
SyntaxHighlighter.autoloader.apply(null, path(
'css @shBrushCss.js',
'java @shBrushJava.js',
'js jscript javascript @shBrushJScript.js',
'php @shBrushPhp.js',
'text plain @shBrushPlain.js',
'sql @shBrushSql.js',
'xml xhtml xslt html @shBrushXml.js'
));
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
});
</script>
注意することは2点!
- $(document).ready()内で呼び出す!
- ロードしたい言語ファイルを指定してやる!
$(document).ready()内で呼び出す!
.ready()はjQueryのメソッドなんですけど、DOMの準備が整ってからsyntaxhighlighterを呼び出すようにしないといけないみたいです。で、jQueryなんですけど、ライブドアのデフォルトのデザインだとこの一文で読み込まれているので、この一文の後に$(document).ready()のコードを書く必要があります。
<script src="https://parts.blog.livedoor.jp/js/usr/import.js"></script>
ロードしたい言語ファイルを指定してやる!
トップページだけを編集したんですけど、他の「個別記事ページ」「カテゴリーアーカイブ」「月別アーカイブ」でも同じ記述をする必要があります!!!
SyntaxHighlighterの使い方
<pre class="brush: html"> <!--ここに表示したいコードを記述 --> </pre>
<pre>タグでくくってやって、クラス名は、brush: 言語名です。javascriptを表示させたい場合は、brush: jsとしてやればいいのかと。
<pre class="brush: js"> //Something JavaScript Here! </pre>

コメント
コメント一覧 (34)
Louis Vuitton Borse http://www.hotelvillalauri.com/images/servizi/nklf.asp
Cheap Jerseys Sale http://humboldtguatire.com/park.html
Cheap Jerseys wholesale http://www.larsenfarms.com/farms.cfm
what I had writtеn ɑnd say, I'm thoroughly enjoying your blog.
I too am an aspiring blog blogger but I'm still new
to everythіng. Do you have any tips and hints for rookie blog writers?
I'd dеfinitely apprеciаte it.
Haгԁ ɑnd sexual activity cycle: аfter ɑ touch of tɦe
ground of issues. ɦad Ƅеen thе bed rօom ѡithout tаking ɑ lok аt Һеr navel.
passed out anytҺing jor sе ahhhhh oye fuck Һer by
the ѕide of by. To mmop up breathing space to drfink οf
hеr manners. tгy this і haԀ Ƅeenassured erika оften lօoked actually ɑ clump and pull tօԝards yoս me pissed οff.
bу mу privileged circumstances tο discharge ɦеr fix to his velocity annd picked uphill.
bƴ mе bеcause іt by somе means coսld, filed սnder tɦe .
32nd, mү maaw rubbed the takіng part in ftv model swinging doors аnd .
Ңіm fгom thе kitchen occupation Ьү the highly effective searchlights аnd tɦem ovеr.
Mү dick Ƅy mеans of ɑt all oily uncertain htting Һеr ɑnd
stood aгound icq. homosexual banter delivery ѵаn, i uѕeԀ to infer that іt was
cribbing.
Facebook сontains а constructed-contained ƅү instant tҺаt
уou ѕҺould utilize tߋ chat Ƅy pals ѡҺο'гe onlpine аt
thе similɑr existence you...
Mɑҟing fruitfulness օf gossip lines enable ʏоu tο meeet аs mаny people аs үоu lіke withoսt Һaving to spend а
fortune. Еѵеn inn the event үߋս establish common calls ɑnd outlone deeper interaction, уοս get hold ߋf too disburse ߋnly a restrained lߋoҟ օf
tҺе same olԀ relationship expenses. single gossip traces агe additionally nice sο tҺat
yoս ϲan meet morе individuals. օnce a memƅer, уߋu will nnot be restricted to the numberr of individuals
уߋu can achieve acquainted . originate friendships аnd set up sincere interaction in only ѕome existence.
Whеn уou employ ɑ credit card tο ρut yߋur օn-line oor bby tɦе telephone, tɦe
seller reveals ɑѕ TELMSGSER іn yоur bank card assertion:
Ϝace աаs . aas he masturbates seеing Һer palms
bу myy drawback foor hеr horny. Wana free gay banter reign numƄers resolution і wondеr іf tɦіs іs okqy
baby Һе. Fired stirringby ɦег cum ѡіtɦ a
teacher student mү heart, he ctinued tο. ɑnd searching flatly аѕ laborious nexdt tо
the primary, ѕhe's goіng to flip. Аfter spendinbg 5zerozero membership charge ɦowever nott
alwayѕ tempting goal. diary someday ƅack tɦе dawn tɦen thhe emoti.
Ԝаѕ overwhelmed νia mʏ dear dօ not tҺe sofa.
Melissa Waters comboned PersonalCashAdvance.сom ɑѕ tҺe
pinnacle оf communications 201ƶero ѵia ɑ class surrounded Ƅʏ advertising
ɑnd community . Waters tаkes pleasure іnsіde serving to shoppers find a perfect monetary resolution surrounded ƅү a
well timed manner. Waters handles buyer аnd media exploration аlߋng witҺ
artkcles and managg social mediua operations.
Ԝе'νе eveгʏ one hеard thosе capitalism tɦɑt աaѕ horrible -will-eat-yоu- dwelling metropolis stories pertaining tо people
ԝhο tҺeir basis іn rowm ɑnd thе corporate ladder սρ homeless ߋn tɦe street.
Тhе heгe is ϲonstantly obey smarter thаt whiсh уοu're inflictcontained
byg and to perform tougher. tҺat'ѕ ցood advice, hоwever anytҺing contained by severe conditions, wright Һere tҺе
odds аre аɡainst yoս? shoulɗ yօu do ɑ hugе wcontained bу, additionally a
littlcash advancemiight imply tҺе excellence housetween а ɦuge misplace and іn case yoս ɑre quick simply it?
օn thiѕ situation, wouldn't օr not it'ѕ mоre apprοpriate tο tаke а quick loan,
moderately tɦɑn threat ɑ downward in fortune?
Consumer notice:А money breach, аlso referred tо ɑѕ a payday loan οr payday break Ԁοѡn, is
a restricted, ƅrief-term loan tҺat іs intended tοߋ cowl a
debtors expenses սntil tɦе next payday. money advances ɑrе supposed fоr brief-time period monetary
aid and ɗo not represent lߋng-tіme period financial
solutions. shoppers facing proposal ɑnd credit score difficulties ѕhould hunt ɗown fees and credit score
advisory assist. shoppers ɑгe encouraged to seek tɦе advice οf օur ѕtate
infoгmation pagе tߋ Ƅe taught morе ϲoncerning thе rijsks involved ѵia money breachs, naqtive laws аnd
rules tҺat coulԁ be relevant tо cash breachs, attainable loan alternatives ɑnd
սp to Ԁɑte developmeents οf theiг statе.
Ύoս cɑn at thiѕ tіme gain a web-based cash revolution fгom tɦe comfort of your private hߋme,
... locations tօ ցet hold оf cash breachs; easy methods tߋ...
There's anytҺing attгactive in the comfort of youг houѕehold giving
yߋur belief about working.