How do I color my source code in posts and comments?

The text in the body field of comments, forum posts, issues, and projects can be syntax colored to make it easy to read. In all cases, surround your code with the tags as indicated below.

  • General code (<code></code>)
    Any text between <code></code> tags will be printed in a monospaced font on a colored background. The <code> tag can be used for any type of code, but is ideal for function names and other short statements since the text won't be syntax highlighted.

    These tags can be used either inline or as a block.

    • To highlight code within a line:
      Execute <code>SetIgorOption IndependentModuleDev=1</code>
      prints as:
      Execute SetIgorOption IndependentModuleDev=1
    • To highlight code as a block:
      <code>
      print IgorInfo(4)
      Intel
      </code>
      prints as:

      print IgorInfo(4)
      Intel
  • Igor Pro (<igor></igor>), C++ (<cpp></cpp>), C (<ccode></ccode>), XML (<xml></xml>)
    Any text between these sets of tags will be displayed in a monotype font and the text will be colored according to the syntax of the language indicated by the tags.

    For example:

    Function Hello(text)
        String text
        DoAlert 1, text
        if (V_flag == 1)
            print "User clicked Yes"
        else
            print "User clicked No"
        endif
    End


    prints as
    Function Hello(text)
        String text
        DoAlert 1, text
        if (V_flag == 1)
        	print "User clicked Yes"
        else
        	print "User clicked No"
        endif
    End

For more information on the various tags that can be used in input fields, see Compose tips.

Back to top