Kali ini saya akan membahas cara memposting source code diblogger, untuk menampilkan source code program pada blog dibutuhkan plugin Syntax Highlighter, Apa itu Syntax Higlighter ? Sintax Highligter merupakan sebuah fitur/ plugin yang digunakan untuk menampilkan source code suatu bahasa pemrograman dalam HTML. Selain untuk menampilkan source code program, alasan lain menggunakan Syntax Highlighter adalah tampilan teks kode akan terlihat lebih rapi, menarik, indah dipandang, serta menjadi pembeda antara bagian tulisan dan source code program. Ikuti langkah dibawah ini:
Langkah - langkahnya:
- Pada Halaman Dasbor, Pilih Rancangan (Design)
- Pada tab Rancangan (Design), Pilih Edit HTML dan Klik Proses
- Terlebih dahulu Backup Template
- Centang | Expand Template Widget
- Cari kode </head> | Tekan Crtl+F
- Selipkan kode dibawah ini diatas </head>
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> <!-- Add-in Script for syntax highlighting --> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shCore.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushAS3.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushBash.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCSharp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushColdFusion.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCpp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCss.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushDiff.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushErlang.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushGroovy.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJScript.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJava.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJavaFX.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPerl.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPhp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPlain.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPowerShell.js'type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPython.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushRuby.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushScala.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushSql.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushVb.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushXml.js' type='text/javascript'/> <script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf'; SyntaxHighlighter.all(); </script>
7. Simpan Template
Bagaimana cara menerapkannya ke Blog ?
Pengaktifan Syntax Higlighter bisa dilakukan dengan 2 cara :
Meggunakan kode Javascript
Contoh :
<script class="brush : Nama alias" type="syntaxhighlighter">
...Source kodemu disini....
</script>
Menggunakan kode HTML
Contoh :
<pre class="brush: Nama Alias">
...Source kodemu disini....
</pre>
<pre class="brush: css"> Kode CSS taruh disini </pre>
<pre class="brush: java"> Kode Javascript taruh disini </pre>
<pre class="brush: html"> Kode HTML taruh disini </pre>
Selengkapnya bisa dilihat pada tabel dibawah ini :
Nama Brush | Alias Brush | Nama File |
---|---|---|
ActionScript3 | as3, actionscript3 | shBrushAS3.js |
Bash/shell | bash, shell | shBrushBash.js |
ColdFusion | cf, coldfusion | shBrushColdFusion.js |
C# | c-sharp, csharp | shBrushCSharp.js |
C++ | cpp, c | shBrushCpp.js |
CSS | css | shBrushCss.js |
Delphi | delphi, pas, pascal | shBrushDelphi.js |
Diff | diff, patch | shBrushDiff.js |
Erlang | erl, erlang | shBrushErlang.js |
Groovy | groovy | shBrushGroovy.js |
JavaScript | js, jscript, javascript | shBrushJScript.js |
Java | java | shBrushJava.js |
JavaFX | jfx, javafx | shBrushJavaFX.js |
Perl | perl, pl | shBrushPerl.js |
PHP | php | shBrushPhp.js |
Plain Text | plain, text | shBrushPlain.js |
PowerShell | ps, powershell | shBrushPowerShell.js |
Python | py, python | shBrushPython.js |
Ruby | rails, ror, ruby | shBrushRuby.js |
Scala | scala | shBrushScala.js |
SQL | sql | shBrushSql.js/td> |
Visual Basic | vb, vbnet | shBrushVb.js |
XML | xml, xhtml, xslt, html, xhtml | shBrushXml.js |
Sumber :
1. http://mfairuzreza.blogspot.com/2011/07/cara-memposting-source-code-di-blog.html
2. http://sharedthisblog.blogspot.com/2012/06/menampilkan-source-code-program-di.html
No comments:
Post a Comment