Adsense-HeaderAd-Script


Advertisement #Header

5 Jul 2014

Online Source Code Syntax Formatter


We can use source code syntax highlighter to format the code style to put in online media's like for e.g: blog or website. One common method is to use javascript to format the source code whenever the page is loaded. ( like SyntaxHighlighter )

SyntaxHighligher has very modern looking code syntax styles and  supports lot of programming languages like  Java, Javascript, PHP, C#, C++, CSS, HTML,  XML, SQL, VB, Python, Ruby.

The only issue with the javascript method is that it takes time to generate the code syntax styles and load the page every time. Its because  javascript tries to search the code for keywords and then renders and build the styles for each page request on the fly.

This issue can be solved, by using Code Syntax Highlight Generator, it builds the source code style only one time and then just simply reuse the rendered style for each page request. This technique notably decreases the load time of the page.

For Online Code Syntax Highlight Generator, visit this link : Online Tool for Syntax Highlight Generator

Steps to use Source Code Syntax Highlight Generator

  1. Insert the source code to the online generator.
  2. Configure the language and display style options
  3. Place the generated HTML to the your desired blog or website.
  4. Add the below CSS and Javascript  library to your blog.
http://ajblk.github.io/codeSyntaxHighlight-Generator/stylesheets/css/stylehighlighter01.css
http://ajblk.github.io/codeSyntaxHighlight-Generator/javascripts/js/sh-min.js
  1. Add the below <script> code snippet  just before the </body> close tag
<script language='javascript'>
var args={presourcecode:"presourcecode",highlighterMainDivId:"highlighterMainDiv"};
//dp.SyntaxHighlighter.BloggerMode(); //Uncomment for Google Blogger.
dp.SyntaxHighlighter.Initialize(args);</script>

A Sample Template:

<html> <head> <link type="text/css" href="stylesheets/css/stylehighlighter01.css" rel="stylesheet"/> <script type='text/javascript' src='javascripts/js/sh-min.js'></script> </head> <body> <!-- Insert The Generated HTML Below This --> <!-- Insert The Generated HTML Above This --> <script language='javascript'> var args = { presourcecode: "presourcecode", highlighterMainDivId: "highlighterMainDiv" }; //dp.SyntaxHighlighter.BloggerMode(); //Uncomment for Google Blogger. dp.SyntaxHighlighter.Initialize(args); </script> </body> </html>



No comments:

Post a Comment