×
Namespaces

Variants
Actions
Revision as of 01:48, 19 November 2012 by hamishwillee (Talk | contribs)

Help:Code Syntax Highlighting

From Nokia Developer Wiki
Jump to: navigation, search
Help.png
This Help topic explains how to add highlighting to code markup in your articles.


For more information see: Extension:SyntaxHighlight_GeSHi (Extension Help). Note that this is a "new plugin" and its native syntax differs from that used on the wiki - which we have maintained for backwards compatability.

Contents

Inline code

Use {{Icode|your inline code fragment}} to markup up code fragments within the body of text. For example: "Class CActive is the base class of all Active Objects"

This maps to the html "tt" tag.

Code blocks

Syntax is as shown below

<code [language] [n]>source code here</code>

Parameters

  • language: Code for any of the supported languages, including C++ (cpp), java.
    List of supported languages
  • n: Line number to start with. A non numeric value (ie "n") will start the list at 001. NOTE that the numbering cycles back to 001 for line numbers greater than 1000.

The examples below show the results from the "default syntax", specifying the language parameters, and displaying line numbers.

Default

<code>
public class MyClass extends SomeOtherClass
{
    public MyClass()
    {
        System.exit(); // surprise, you're dead!
    }
}
</code>
public class MyClass extends SomeOtherClass
{
public MyClass()
{
System.exit(); // surprise, you're dead!
}
}

Specify language (java)

<code java>
public class MyClass extends SomeOtherClass
{
    public MyClass()
    {
        System.exit(); // surprise, you're dead!
    }
}
</code>
public class MyClass extends SomeOtherClass
{
public MyClass()
{
System.exit(); // surprise, you're dead!
}
}

Line numbers starting from one

<code cpp n>
int main(int argc,char *argv){
   int d;
   d = argc + 1;
}
</code>
  1. int main(int argc,char *argv){
  2.    int d;
  3.    d = argc + 1;
  4. }

Line numbers starting from specified value

<code cpp 6>
int main(int argc,char *argv){
   int d;
   d = argc + 1;
}
</code>
  1. int main(int argc,char *argv){
  2.    int d;
  3.    d = argc + 1;
  4. }
 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×