Powered by Blogger.

Integrate Syntax Highlighter to Blogger


Integrate Syntax Highlighter to Blogger

SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript. Basically, it highlights your code based on the language you've specified.

Example:

<?php echo "this is a syntax highlighter.";?>

Step 1. Go ahead and log in to your blogger account. Navigate to Template > Edit HTML




Step 2. Add the following code before the closing head tag.

<!-- INCLUDE SyntaxHighlighter Components (css and javascript) -->
 <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>
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
 <!-- END INCLUDE SyntaxHighlighter Components -->
 
 <!-- INCLUDE YOUR BRUSHES WHICH YOU WANT TO USE HERE -->
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushXML.js" type="text/javascript"></script>
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
 <script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
 <!-- END INCLUDE BRUSHES -->
 <!-- INIT SyntaxHighlighter -->
 <script type="text/javascript">
           SyntaxHighlighter.config.bloggerMode = true;
           SyntaxHighlighter.all();
 </script>
 <!-- END INIT SyntaxHighlighter -->

You can include other language syntax highlighter by adding scripts on your header with the following file names

Brush nameBrush aliasesFilename

ActionScript3
as3, actionscript3shBrushAS3.js

Bash/shell
bash, shellshBrushBash.js

ColdFusion
cf, coldfusionshBrushColdFusion.js

C#
c-sharp, CSharpshBrushCSharp.js

C++
CPP, cshBrushCpp.js

CSS
cssshBrushCss.js

Delphi
delphi, pas, pascalshBrushDelphi.js

Diff
diff, patchshBrushDiff.js

Erlang
erl, erlangshBrushErlang.js

Groovy
groovyshBrushGroovy.js

JavaScript
js, jscript, javascriptshBrushJScript.js

Java
javashBrushJava.js

JavaFX
jfx, javafxshBrushJavaFX.js

Perl
perl, plshBrushPerl.js

PHP
phpshBrushPhp.js

Plain Text
plain, textshBrushPlain.js

PowerShell
ps, powershellshBrushPowerShell.js

Python
py, pythonshBrushPython.js

Ruby
rails, ror, rubyshBrushRuby.js

Scala
scalashBrushScala.js

SQL
sqlshBrushSql.js

Visual Basic
vb, vbnetshBrushVb.js

XML
xml, xhtml, xslt, html, xhtmlshBrushXml.js

No comments