aswal94
aswal94

Reputation: 145

How to install syntax highlighter on wordpress?

I want to integrate Syntax Highlighter on my wordpress blog. I've searched over internet for it but haven't got the answer.

I tried to link the sytax highlighter by switching the blog writing mode to html from visual but still it's not working.

There are answers which says that this can't be done on free wordpress blog but recently i visited this blog :

tausiq.wordpress.com/2013/01/19/android-input-field-validation/

This blog have accomplished this task. I want to know how this is possible.

Upvotes: 0

Views: 140

Answers (3)

Serge V.
Serge V.

Reputation: 3613

Install a plugin called Crayon Syntax Highlighter. It got more than 50 theme. https://wordpress.org/plugins/crayon-syntax-highlighter/screenshots/
Here is one of it: enter image description here

Upvotes: 0

Gergő Kajtár
Gergő Kajtár

Reputation: 492

Also you can edit your current template header.php file. Include the Syntax Highlighter js and css files.

After you included, use the <pre class="brush:php;"><?php echo 'Your example code'; ?></pre> code on the post/page content editor page (HTML mode).

<!--SYNTAX HIGHLIGHTER BY MBT STARTS--> 
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shCore.css' rel='stylesheet' type='text/css'/> 
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shCore.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCpp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCSharp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCss.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushJScript.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPhp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPython.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushRuby.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushSql.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushVb.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushXml.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPerl.js' type='text/javascript'/> 
<script language='javascript'> 
SyntaxHighlighter.config.bloggerMode = true; 
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/2.1.382/scripts/clipboard.swf&#39;; 
SyntaxHighlighter.all(); 
</script> 
<!--SYNTAX HIGHLIGHTER BY MBT ENDS-->

Upvotes: 1

aswal94
aswal94

Reputation: 145

Got the answer:

The blog is using [code language='language']..[/code], it is not using syntax highlighter.

The list of values for languages is provided at: https://en.support.wordpress.com/code/posting-source-code/

Upvotes: 0

Related Questions