My wish to blog about some Ruby'n'Rails stuff is coming true and Boom! there was the first issue. How to hightlight the syntax of the ruby code snippets? Gosh! But fortunately there is the SyntaxHighlighter :) based on CSS and JavaScript. Now i describe how I got it working.
I promise you, it's done in 3 steps.Step 1
Download the SyntaxHighlighter (just follow the link above) and you should receive a lot of files.
The shCore.js and SyntaxHighlighter.css are essentially. The first one makes the code looking as the second file wants it to look like: Bling Bling.
The rest of JS pack are shBrushXXX.js files amongst others the shBrushRuby.js. Now you have to park them somewhere in the world wild web. I abused Geocities for it but Google's Sites should do the job the same. It doesn't matter. The main point is that they are available. Otherwise no Bling Bling.
To be able to highlight more kind of code like SQL, CSS, JScript or XML I uploaded the appropriate shBrushSql.js, shBrushCss.js, shBrushJScript.js and shBrushXml.js too.Step 2
Before getting the code snippets sparkling you better should include the needed files inside the head tags as I did:
<link type="text/css" rel="stylesheet" href="http://your_server/path/to/SyntaxHighlighter.css"> <script src="http://your_server/path/to/shBrushRuby.js" language="javascript"></script> <script src="http://your_server/path/to/shBrushSql.js" language="javascript"></script> <script src="http://your_server/path/to/shBrushCss.js" language="javascript"></script> <script src="http://your_server/path/to/shBrushJScript.js" language="javascript"></script> <script src="http://your_server/path/to/shBrushXml.js" language="javascript"></script>and before the closing body tag
Keine Kommentare:
Kommentar veröffentlichen