Posting Source Code in Blogspot

Ever some day,I am in confused when I will post a note in the Blogspot, in the note there are some code XML program. The happens is that the source code was not able to appear at the post on blogger. So that the source code can not be in the show, after I find a reference, with Uncle Google, of course. Finally, I get a load of the ways that post which there source code, so that the source code can be in the show on my blog posts.

In the post this time We will study how the configuration of the post so that there is in the source code that can be displayed on the blogspot. Even here, we can determine what type of programming language in use. Here we will use SyntaxHighlighter the later work to change the source code in accordance with the type of programming language and can be displayed at Blogspot.

To make this work on blogger, do the following:

  1. Download SyntaxHighlighter here
  2. Unzip and upload the following files to your webspace or you can use from http://sakkarepku.co.cc/resource
    • SyntaxHighlighter.css
    • shCore.js'
    • shBrushCpp.js (or whatever code you wish to use on your blog) …
  3. Go to your Dashboard/Layout/Edit HTML
  4. Add the following code right before your </head> tag in the HTML of your blogger template (or wherever you may find yourself in a need of a syntax highlighter). just remove any lines for languages you don't use...

  <link href="http://sakkarepku.co.cc/resource/Styles/SyntaxHighlighter.css" rel="stylesheet" type="text/css"><br /> <br /> <script language="javascript" src="http://sakkarepku.co.cc/resource/Scripts/shCore.js"> <br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushCpp.js'/"> <br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushCSharp.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushCss.js'/"> <br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushDelphi.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushJava.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushJScript.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushPhp.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushPython.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushRuby.js'/"><br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushSql.js'/"> <br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushVb.js'/"> <br /> <script language="'javascript'" src="'http://sakkarepku.co.cc/resource/Scripts/shBrushXml.js'/"> <br /> <script language="'javascript'"> dp.SyntaxHighlighter.BloggerMode(); dp.SyntaxHighlighter.HighlightAll('code'); </script><br /> 

Now to add source code to a post, it should be placed in textarea tag. Obviously, you have to do this within the "Edit Html" tab of the Google editor. The typical format that I use is

<script type="syntaxhighlighter" class="brush: html"><![CDATA[<html><head><title>Carter Tomorrow Fund Donations</title><meta name="title" content="Help Give to the Carter Tomorrow Fund" /> <meta name="description" content="Show your support and help out with a small gift" ]]></script>

or use this is not compatible:

<pre class="brush:xml">...insert code here...</pre>
survivors try :D

Comments