Formatting Source Code With Syntax Highlighting
By Drew Wells @ 1:56 AM
To display source code with syntax coloring and nice formatting like this:
Just use HTML edit mode and wrap your code in a
<textarea name=code class=c#> tag. Your code will be
formatted with spaces and line breaks just like you enter it into the
edit box.
Here's an example of how the code will look in the HTML edit view:
The rows and cols are only used if the browser doesn't support the advanced formatting in the syntax highlighter.
You can use:
<textarea name=code class=delphi>
<textarea name=code class=c#>
<textarea name=code class=vb>
<textarea name=code class=jscript>
<textarea name=code class=sql>
<textarea name=code class=xml>
Checklist:
- Use HTML edit mode to add your source code.
- Start your source with <textarea name=code class=c#> where class=language has your language name.
- Whatever spaces and line breaks you put in the <textarea> while in HTML edit mode will be displayed.
- Close your source textarea with the </textarea> tag.
- You can use the rows and cols property for browsers that don't support the nice formatting.
Here's the link to the full documentation:
Syntax Highlighter
You can also get there from the ? link at the top of the code listing.