Code in the Comments

Code in the Comments

Posted in:

We get a lot of comments here on the blog and, surprise surprise, many of them include code. You may have noticed that in all of our posts we have nicely formatted and color highlighted code - and now, anyone can use this feature in our comments. This is done simply by using formatting like the following:

[csharp]
GraphicsPath p = new GraphicsPath();
p.StartFigure();

//Top Left Corner
if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft)
{
  p.AddArc(x, y, 2*radius, 2*radius, 180, 90);
}
else
{
  p.AddLine(x, y+radius, x, y);
  p.AddLine(x, y, x+radius;, y);
}

//Top Edge
p.AddLine(x+radius, y, x+width-radius, y);
[/csharp]

Now this will turn into:

GraphicsPath p = new GraphicsPath();
p.StartFigure();

//Top Left Corner
if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft)
{
  p.AddArc(x, y, 2*radius, 2*radius, 180, 90);
}
else
{
  p.AddLine(x, y+radius, x, y);
  p.AddLine(x, y, x+radius;, y);
}

//Top Edge
p.AddLine(x+radius, y, x+width-radius, y);

Now this technique works for almost any language we use here on the site including:

  • csharp
  • xml
  • mxml
  • actionscript
  • javascript
  • html
  • css
  • php

For general code you can use "code", so [code]. The syntax highlighting is done using a Wordpress plugin called iG:Syntax Hiliter which uses Geshi for the highlighting. We will at some point in the future be offering up the custom files that we made for mxml and other languages. Hopefully this makes all of our commenter's lives easier.

Frederic Vandenplas
11/03/2008 - 14:06

can i mail it to U ?
greetings
frederic

reply

The Reddest
11/03/2008 - 14:10

Sure, the email address is located at the bottom of the About page.

reply

Add Comment

Put code snippets inside language tags:
[language] [/language]

Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]

See here for supported languages.

Javascript must be enabled to submit anonymous comments - or you can login.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.