Wikipedia:WikiProject C/C++/Syntax highlighting

{{historical}}

It would be nice to make full use of HTML's facility with text formatting in code samples. Following are proposals for syntax highlighting.

Standard colors

While the usual white or off-white background is reasonably well suited for plain encyclopedic text, it's poor at providing the contrast needed to easily distinguish color. Thus, colored text should preferably be placed on a dark background to allow a broad range of colors to be used. Note, however, that pure blue is less visible against black than against white.

The default colors are proposed to be as follows (it will of course be possible to override them with style sheets):

border="1" cellspacing="0" cellpadding="3" style="color: #cccccc"
style="font-family: serif" | Color

! style="font-family: serif" | RGB triplet

! style="font-family: serif" | Uses

style="color: #ffffff" | White

| style="color: #ffffff" | #ffffff

| style="font-family: serif" | keywords

style="color: #ff0000" | Red

| style="color: #ff0000" | #ff0000

| style="font-family: serif" | decimal numbers

style="color: #ff8000" | Orange

| style="color: #ff8000" | #ff8000

| style="font-family: serif" | octal numbers

style="color: #ffff00" | Yellow

| style="color: #ffff00" | #ffff00

| style="font-family: serif" | characters, strings

style="color: #00ff00" | Green

| style="color: #00ff00" | #00ff00

| style="font-family: serif" | preprocessor symbols

style="color: #00ffff" | Cyan

| style="color: #00ffff" | #00ffff

| style="font-family: serif" | function names

style="color: #0000ff" | Blue

| style="color: #0000ff" | #0000ff

| style="font-family: serif" | ?

style="color: #ff00ff" | Magenta

| style="color: #ff00ff" | #ff00ff

| style="font-family: serif" | hexadecimal numbers

style="color: #a00000" | Dark red

| style="color: #a00000" | #a00000

| style="font-family: serif" | ?

style="color: #a05000" | Dark orange

| style="color: #a05000" | #a05000

| style="font-family: serif" | ?

style="color: #a0a000" | Dark yellow

| style="color: #a0a000" | #a0a000

| style="font-family: serif" | comments

style="color: #00a000" | Dark green

| style="color: #00a000" | #00a000

| style="font-family: serif" | ?

style="color: #00a0a0" | Dark cyan

| style="color: #00a0a0" | #00a0a0

| style="font-family: serif" | punctuation

style="color: #0000a0" | Dark blue

| style="color: #0000a0" | #0000a0

| style="font-family: serif" | ?

style="color: #a000a0" | Dark magenta

| style="color: #a000a0" | #a000a0

| style="font-family: serif" | ?

style="color: #cccccc" | Gray

| style="color: #cccccc" | #cccccc

| style="font-family: serif" | everything else

style="color: #a0a0a0" | Dark gray

| style="color: #a0a0a0" | #a0a0a0

| style="font-family: serif" | ?