Style Guide

From J Wiki
Jump to navigation Jump to search

J Wiki Style Guide

The following are guidelines for styling J wiki pages.

1. Definitions and executed examples should be in <syntaxhighlight lang=J></syntaxhighlight> tags.

If the example is just a list of definitions, they should written as in a script, and usually flushed left. Otherwise, definitions and sentences executed should be indented 3 spaces, and output shown as in the terminal. Where possible, align comments vertically for greater readability. Examples:

rnd=: ?@#&0             NB. random numbers in range (0,1)  
cumwts=: +/\ % +/       NB. cumulative weights
   rnd=: ?@#&0
   rnd 5
0.5377 0.06353 0.7059 0.5188 0.8832

2. J code and names in ordinary text should be wrapped in <code></code> tags. If the J code has wiki markup, then also use the nowiki tag, i.e. wrap in the pair of tags:

<code><nowiki></nowiki></code>.

Do not use the <code></code> tags for non-J code, as this can be confusing. In particular, mathematical expressions should be written in plain ascii or in Latex. For example, the following sentence has mathematical and J expressions:

The J equivalent of cos(x) + i sin (x) is (cos x) + i * sin x.

3. In text, words being defined may be italicized, but otherwise avoid highlighting text with italics, bold and underscore. The Wiki is more readable without fussy formatting.

4. Use wiki markup wherever appropriate (e.g. for lists and tables), rather than raw html or inventing your own. Tables are best in wikitable style, e.g.

{| class="wikitable"
! style="text-align:left" | header1
! style="text-align:left" | header2
|-
| cell11
| cell12
|-
| cell21
| cell22
|}

becomes:

header1 header2
cell11 cell12
cell21 cell22

5. A colon at the beginning of a line indents it, otherwise use &nbsp; for spacing:

: <code>?</code> (deal) &nbsp; <code>{:</code> (take) &nbsp; <code>#</code> (copy) &nbsp; <code>I.</code> (interval index)

becomes:

? (deal)   {: (take)   # (copy)   I. (interval index)

6. With LaTeX, where appropriate use a math display style of inline or block, i.e. <math display="inline"> or <math display="block">, for example:

This expression uses the inline style:

This uses the block style: