Wit

Core vocabulary

The 52 names that need no definition, with the HTML each emits and the parameters it reads. Each one-line use below works in either form — @em x em@ or (em x em). Also here: the opaque @node and the raw nodes.

Headings — 6

h1 … h6 emit the same tag with id / class. A one-line heading holds no <p>.

source
(h1 Title h1)
@h2(id: methods) Methods h2@
result

Title

Methods

<h1>Title</h1><h2 id="methods">Methods</h2>

Inline — 12

Inline
NodeEmits
emem
strongstrong
codecode — body escaped
uu
ss
subsub
supsup
markmark
smallsmall
spanspan
citecite
brbr — void
source
(strong Bold strong), (code x < y code), H@sub 2 sub@O, 12 km@sup 2 sup@ and
line one@br
line two.
result

Bold, x < y, H2O, 12 km2 and line one
line two.

<p><strong>Bold</strong>, <code>x &lt; y</code>, H<sub>2</sub>O, 12 km<sup>2</sup> and
line one<br> line two.</p>

em and strong are the explicit form of _x_ and *x*. A known node may follow a word directly when not followed by ., so emails stay prose. code escapes its body but still reads Wit inside; for verbatim text use @@code … code@@.

Lists — 6

ul, ol, li, dl, dt, dd — same tag, id / class.

source
@ul
(li First li)
(li Second li)
ul@

@dl
(dt Term dt)
(dd Definition dd)
dl@
result
  • First
  • Second
Term
Definition

For data-driven lists, loop a collection — see data model.

Links and media — 6

Typed parameters
NodeParametersNotes
ahref and target plus id and classhref is literal; no href renders as #
imgsrc and alt and width and height and size and alignvoid; src is literal
figuresize and alignalign sets text-align on image and caption
figcaptionid and class—
audiosrc and controlscontrols: true is a flag; false is off
videosrc and controlsthe body renders inside as fallback
(a(href: https://en.wikipedia.org/wiki/Mercury_(planet), target: _blank) Mercury a)

@img(src: p.jpg, alt: A lamp, size: medium, align: center)

@figure(align: center)
@img(src: p.jpg, alt: A lamp)
(figcaption The lamp, 1923. figcaption)
figure@

@audio(src: clip.mp3, controls: true) audio@
<p><a href="https://en.wikipedia.org/wiki/Mercury_(planet)" target="_blank">Mercury</a></p>
<img src="p.jpg" alt="A lamp" style="max-width:380px;height:auto;display:block;margin-left:auto;margin-right:auto">
<figure style="text-align:center"><img src="p.jpg" alt="A lamp"><figcaption>The lamp, 1923.</figcaption></figure>
<audio src="clip.mp3" controls></audio>
size on img and figure
ValueCompiles to
smallmax-width:220px
mediummax-width:380px
largemax-width:600px
a bare number N or Npxmax-width:Npx
fullwidth:100%
a percentwidth:N%

Presets and pixel values cap the width and never upscale; full and percents fill. align: center centres the block; left / right push it to that side.

Tables — 8

table has its own renderer; thead, tbody, tfoot, tr, th, td and caption build one by hand, and their cells may hold any inline Wit.

table parameters
ParameterMeaning
rowsa collection of rows; row 0 is the header — or a reference to one
schemaa record that picks and labels columns of a list of records; or a list of keys
captiona caption
headerfalse for no header row; a list to supply one
source
#sites: [
  { name: Dunmore Head, status: operational }
  { name: Carrick Point, status: maintenance }
] !!

@table(caption: Hours, rows: [[Client, Total], [One to one, 104]])

@table(schema: { name: Site, status: Status }, rows: @sites)

@table
@thead
@tr (th Term th) (th Meaning th) tr@
thead@
@tbody
@tr (td (code x < y code) td) (td _anything_ inline td) tr@
tbody@
table@
result
Hours
ClientTotal
One to one104
SiteStatus
Dunmore Headoperational
Carrick Pointmaintenance
TermMeaning
x < yanything inline

More in Tables.

Blocks — 5

p, blockquote, pre, div take id / class; hr is void. A block element on its own line ends the paragraph before it.

source
@blockquote
Interviewer: How was it?
P12: Honestly, fine.
blockquote@

@div(class: card)
Body.
div@

@hr
result

Interviewer: How was it? P12: Honestly, fine.

Body.


<blockquote><p>Interviewer: How was it?
P12: Honestly, fine.</p></blockquote><div class="card"><p>Body.</p></div><hr>

pre escapes its body and keeps its lines; for text that must not be read as Wit use @@pre … pre@@.

Sectioning — 7

section, article, aside, header, footer, nav, main — same tag, block, id / class. Opening one on its own line needs its close (E_UNCLOSED_NODE).

source
@section(id: results)
(h2 Results h2)
The beam swept the harbour.
section@
result

Results

The beam swept the harbour.

Layout — 2

row is an invisible flex band; each col is a column. size fixes a column's width (small 220px, medium 380px, large 600px, a number, px or a percent); a column without one fills. Columns stack when the row is narrow.

@row
@col(size: 220)
@img(src: p.jpg, alt: A lamp)
col@
@col
The lamp was lit at dusk.
col@
row@

Opaque node

@node(type: x, …) passes every parameter to the renderer. When type is a core name it renders as that element; otherwise the HTML renderer emits a div with each parameter as a data-* attribute. Any identifier is a key here.

source
@node(type: box, role: note)
Hi.
node@
result

Hi.

<div data-type="box" data-role="note"><p>Hi.</p></div>

Raw nodes

Raw names
NameEmits
stylea style element — body verbatim
scripta script element — body verbatim
codecode — escaped
prepre — escaped and lines kept
mathinline MathML from AsciiMath
mathblockblock MathML
diagrama pre with class wit-diagram mermaid

@@name … name@@ keeps its body verbatim but fills {{path}} holes; @@@name … name@@@ fills nothing.

source
#theme: { accent: teal } !!

@@style .lead { color: {{theme.accent}} } style@@

Area: @@math pi r^2 math@@.
result

Area: πr2.

Unresolved output

InputEmits
@name with no definitionE_UNRESOLVED_REFERENCE
a missing field @a.b<span class="wit-unresolved">@a.b</span>
::name:: outside a definition<span class="wit-unresolved">::name::</span>
a bare record or collection<div class="wit-node" data-wit-name="name"></div>

See also

Syntax · Tables · Images & media · Data model · Limitations.