New Syntax Highlighting in Forums and Journals
Posted by Michael Tanczos,
21 April 2011
·
733 views
We've introduced an old favorite for syntax highlighting code in our forums and journals. In addition to the standard [ code ] tags that exist now, we have introduced a tag that we used to use readily in past versions of GameDev.net. The "new" bbcode tag that is available for use is the [ source ] tag.
The source tag requires an attribute specifying what language you want to use. Available language options are:
Before:
[ source lang="csharp"] <-- remove space before 'source'
using System;
using System.IO;
class Test {
private static void Main() {
for (int i = 0; i < 5000; i++) {
using (TextWriter w = File.CreateText("C:\\tmp\\test\\log" + i + ".txt")) {
string msg = DateTime.Now + ", " + i;
w.WriteLine(msg);
Console.Out.WriteLine(msg);
}
}
Console.In.ReadLine();
}
}
[ /source ]
After:
[source lang="csharp"][color="#000000"]using System;using System.IO;class Test { private static void Main() { for (int i = 0; i < 5000; i++) { using (TextWriter w = File.CreateText("C:\\tmp\\test\\log" + i + ".txt")) { string msg = DateTime.Now + ", " + i; w.WriteLine(msg); Console.Out.WriteLine(msg); } } Console.In.ReadLine(); }}[/color][/source]
The source tag requires an attribute specifying what language you want to use. Available language options are:
Language Tag Argument ActionScript3 as3, actionscript3 Bash/shell bash, shell ColdFusion cf, coldfusion C# c-sharp, csharp C++ cpp, c CSS css Delphi delphi, pas, pascal Diff diff, patch Erlang erl, erlang Groovy groovy JavaScript js, jscript, javascript Java java JavaFX jfx, javafx Lua lua Perl perl, pl PHP php Plain Text plain, text PowerShell ps, powershell Python py, python Ruby rails, ror, ruby Scala scala SQL sql Visual Basic vb, vbnet XML xml, xhtml, xslt, html, xhtml
Before:
[ source lang="csharp"] <-- remove space before 'source'
using System;
using System.IO;
class Test {
private static void Main() {
for (int i = 0; i < 5000; i++) {
using (TextWriter w = File.CreateText("C:\\tmp\\test\\log" + i + ".txt")) {
string msg = DateTime.Now + ", " + i;
w.WriteLine(msg);
Console.Out.WriteLine(msg);
}
}
Console.In.ReadLine();
}
}
[ /source ]
After:
[source lang="csharp"][color="#000000"]using System;using System.IO;class Test { private static void Main() { for (int i = 0; i < 5000; i++) { using (TextWriter w = File.CreateText("C:\\tmp\\test\\log" + i + ".txt")) { string msg = DateTime.Now + ", " + i; w.WriteLine(msg); Console.Out.WriteLine(msg); } } Console.In.ReadLine(); }}[/color][/source]
Create a custom theme




