Wednesday, November 17, 2010

Javascript for Syntax Highlighting

Try this for beautiful syntax highlighter written in javascript.
Insert your code in a <pre> tag and it will be pretty.

<link type="text/css" rel="stylesheet" href="http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css"></link>


<pre name="code" class="java">
public class Fun {

public static void main(String arg[]) {
System.out.println("Hello Beautiful World\n");
}

}
</pre>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js"></script>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJava.js"></script>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js"></script>
<script language="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>

No comments: