When you make some programming code in any IDE (Integrated Development Environment), they are formatted to be read easily. But when you post them on a blog/website, everyone only see them in plain text formatting. It's inconvenient. SyntaxHighlighter, a JavaScript module, will help you to solve this problem.
- Open your blog/website html template, insert below tag below code:
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js">
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = false;
SyntaxHighlighter.all();
</script>
Note: in code line 2, bloggerMode = true if you use SyntaxHighlighter for your blogger blog.- Then, every time you want to post some programming code, on html editor, you just need to surround them with:
<pre class="brush:language">your code here</pre>
or
<script type="syntaxhighlighter" class="brush:language "><![CDATA[your code here]]></script>
- Some brush for your code:
- C#: c-sharp, csharp
- C++: cpp, c
- JavaScript: js, jscript, javascript
- Java: java
- PHP: php
- PowerShell: ps, powershell
- SQL: sql
- HTML/XML: xml, xhtml, xslt, html, xhtml
- More here
Here is an example:
[html]<pre class="brush:csharp;">for(int i = 0; i < 100; i++)
{
MessageBox.show("Hello World!");
}</pre>[/html]
=> Result:
for(int i = 0; i < 100; i++)
{
MessageBox.show("Hello World!");
}
With succeed!
Comments
Post a Comment