Solved

How to add code syntax highlighting to blogger

Posted on 2012-04-04
8
362 Views
Last Modified: 2012-04-27
I'm new to blog. I would like to add my powershell code to the blog. I had difficulty to follow below links.


http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html

http://alexgorbatchev.com/SyntaxHighlighter/

I try to use syntaxhighlighter to add code but i have difficult to follow their instruction:


Installation


Basic Steps

To get SyntaxHighlighter to work on you page, you need to do the following:
1.Add base files to your page: shCore.js and shCore.css
2.Add brushes that you want (for example, shBrushJScript.js for JavaScript, see the list of all available brushes)
3.Include shCore.css and shThemeDefault.css
4.Create a code snippet with either <pre /> or <script /> method (see below)
5.Call SyntaxHighlighter.all() JavaScript method

<pre /> method

ADVANTAGES: Works everywhere, graceful fallback if there are script problems, shows up in all RSS readers as regular <pre />

PROBLEMS: Major issue with this method is that all right angle brackets must be HTML escaped, eg all < must be replaced with &lt; This will ensure correct rendering.

SyntaxHighlighter looks for <pre /> tags which have a specially formatted class attribute. The format of the attribute is the same as the CSS style attribute. The only required parameter is brush (see configuration), which should be set as one of the brush aliases

Start from step1, i already no idea to do that.

Please advice
0
Comment
Question by:suriyaehnop
  • 4
  • 3
8 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37809537
Is this Blogger or WordPress?
0
 
LVL 18

Author Comment

by:suriyaehnop
ID: 37809581
Wordpress and blogspot. I have 2 blogs
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37809587
Wordpress.com or self-hosted?
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 18

Author Comment

by:suriyaehnop
ID: 37809609
sorry// wordpress.com
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 300 total points
ID: 37814393
For Wordpress.com all you need to do is put the code in the sourcecode shortcode per their instructions:

http://en.support.wordpress.com/code/posting-source-code/

Example:

[sourcecode language="css"]
your code here
[/sourcecode]
0
 
LVL 18

Author Comment

by:suriyaehnop
ID: 37826271
Working on wordpress.com. Do you how to enable it on blogspot also?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 37826302
0
 
LVL 12

Expert Comment

by:Anuradha Goli
ID: 37827488
You can add as per instructions shown in link
http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html
if any doubts please let me know
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question