To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
To LUGNET News Traffic PageSign In (Members)
 Publishing / FTX / User Guide / code

Computer code

Word mode

To express a word or phrase in a computer-style (or typewriter-style) typeface, for example a key on the keyboard or something you would like a reader to type, use a pair of vertical bar characters around words. Vertical bar characters in FTX activate HTML’s <TT> (teletype) font, for example:

You write...

Press the |Enter| key.

You get...

Press the Enter key.


Since the vertical bar is special, you need to use a backtick if you want to display an actual vertical bar character -- just as you would for {, }, [, ], <, and >. For example:

You write...

I can write |teletype stuff| and I can write vertical bars `|.

You get...

I can write teletype stuff and I can write vertical bars |.


Between vertical bars, {, }, [, ], <, >, and _ are automatically protected from their normal FTX interpretations. That is, in the context of displaying computer code, { and } do not produce italics, [ and ] do not produce boldface, < and > do not produce links, and pairs of _ do not produce underlined text. Instead, these characters appear naturally, for example:

You write...

The size is given by |$foo_bar->[zot]{glort}|, if present.

You get...

The size is given by $foo_bar->[zot]{glort}, if present.


However, when writing computer code in word mode (using a delimited pair of vertical bar characters), you do still need to use a backtick character for ` and | inside a pair of vertical bars, for example:

You write...

The vector |$C| is computed as |$A`|$B|.
By far my favorite shell idiom is |...`|sort`|uniq -c`|sort -n|.

You get...

The vector $C is computed as $A|$B. By far my favorite shell idiom is ...|sort|uniq -c|sort -n.


Block mode

You can also express entire blocks of text as pre-formatted text in the teletype font by using a vertical bar followed by a space at the beginning of each such line, for example:

You write...

| int main(int argc, char *argv[])
| {
|    ...
| }

You get...
int main(int argc, char *argv[])
{
   ...
}
In block modes, all characters on the line (after the initial vertical bar and accompanying space character) are protected from their normal FTX interpretations -- even ` and |. Thus, you can take any block of computer code and prefix it with a vertical bar (and a space) without any worries.

Block modes require a space character after the initial vertical bar in order to prevent accidental interpretation of word-mode (delimited pairs of vertical bars) as block mode when a short computer word or phrase in a regular paragraph happens to appear at column 1. This space character is purely syntactical and is not treated as part of your actual line. Subsequent space characters, however, are treated as part of your actual line.


Double block mode

You can use two vertical bars followed by a space at the beginning of each line in a paragraph to show that block in a lightly shaded background with a thin border, for example:

You write...

|| int main(int argc, char *argv[])
|| {
||    ...
|| }

You get...

int main(int argc, char *argv[])
{
   ...
}
All text, images, or trademarks in this document are the intellectual property of their respective owners.


©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR