วันเสาร์ที่ 11 เมษายน พ.ศ. 2552

Trying SyntaxHighlighter -- javascript syntax highlight source code

You can d/l SyntaxHighlighter from here หน้าใหม่.

To use it, include javascript in your page i.e.
<!-- Start SyntaxHighlighter -->
<link href='http://dsin.appspot.com/static/css/SyntaxHighlighter/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shCore.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushCSharp.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushPhp.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushJScript.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushJava.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushVb.js'></script>

<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushSql.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushXml.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushDelphi.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushPython.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushRuby.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushCss.js'></script>
<script class='javascript' src='http://dsin.appspot.com/static/js/SyntaxHighlighter/shBrushCpp.js'></script>
<script class='javascript'>
window.onload = function(){
dp.SyntaxHighlighter.ClipboardSwf = "http://dsin.appspot.com/static/swf/SyntaxHighlighter/clipboard.swf";
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll("code");};
</script>
<!-- End SyntaxHighlighter -->


If you wanna use,
<pre name="code" class="php">
// your php code here
</pre>


Other Support Language

Language| Aliases
C++  | cpp, c, c++
C#  | c#, c-sharp, csharp
CSS  | css
Delphi  | delphi, pascal
Java  | java
Java Script | js, jscript, javascript
PHP  | php
Python  | py, python
Ruby  | rb, ruby, rails, ror
Sql  | sql
VB  | vb, vb.net
XML/HTML | xml, html, xhtml, xslt
full list of brush is here.

หรือไปใช้ที่เวปมันเลย ตามนี้
<!-- Start SyntaxHighlighter -->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shLegacy.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js'></script>
<script language='javascript'
src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js'></script>
<script language='javascript' src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js'></script>
<script class='javascript'>
window.onload = function(){
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll("code");};
</script>
<!-- End SyntaxHighlighter -->


ถ้าเขียนใน wordpress.com อ่านนี่

ไม่มีความคิดเห็น:

LinkWithin

Related Posts Plugin for WordPress, Blogger...