8 November 2026
Blocks, not HTML
nimib exists to make custom blocks easy, so that a page says what it shows and not how it is
drawn: nbTable t rather than a <div> around a string of HTML. tabelline's pages drifted the
other way. They write HTML inside nbText, paste it with nbRawHtml, carry their own <style>
and <script>, and write colours as hex values where they need them. This post measures how far
the drift went, proposes the blocks that would replace it (one of them works already, below), says
where styles and colours should live, and what a nimib skill should teach so that agents, which
wrote most of these pages, don't drift again.
This page has no HTML in its text and no nbRawHtml: it is written only with nimib's blocks,
tabelline's nbTable and the first custom block.
How far it drifted
Every .nim file under docs/ was read on 8 November 2026 (the numbers are kept as a dated
snapshot, so they stay what they were when this was written). Outside the theme, the
18 pages call nbRawHtml 35 times, write HTML tags inside 25
nbText blocks, carry 10 <style> and 5 <script> blocks of
their own, and write 101 distinct hex colours between them.
| HTML, CSS and colours in the pages | ||||||
|---|---|---|---|---|---|---|
| per source file, on 8 November 2026 | ||||||
| nbRawHtml | nbText with HTML | <style> | <script> | style= | hex colours | |
| living documents | ||||||
design.nim | 6 | 3 | 2 | 0 | 7 | 14 |
specs.nim | 6 | 0 | 1 | 1 | 0 | 7 |
index.nim | 4 | 1 | 0 | 1 | 0 | 1 |
explainer.nim | 1 | 3 | 1 | 0 | 0 | 12 |
coverage.nim | 0 | 1 | 0 | 0 | 0 | 5 |
roadmap.nim | 0 | 1 | 0 | 0 | 0 | 1 |
agents.nim | 0 | 1 | 0 | 0 | 0 | 0 |
| posts | ||||||
devlog/palettes.nim | 7 | 4 | 2 | 1 | 9 | 31 |
devlog/tabellone.nim | 1 | 2 | 1 | 2 | 3 | 4 |
devlog/design_review.nim | 4 | 1 | 1 | 0 | 17 | 20 |
devlog/designing_0_1.nim | 4 | 1 | 1 | 0 | 0 | 5 |
devlog/skills.nim | 1 | 1 | 0 | 0 | 0 | 0 |
devlog/day_one.nim | 0 | 1 | 1 | 0 | 0 | 1 |
devlog/month_of_building.nim | 0 | 2 | 0 | 0 | 0 | 0 |
devlog/two_looks.nim | 0 | 1 | 0 | 0 | 0 | 0 |
devlog/operetta.nim | 0 | 1 | 0 | 0 | 0 | 0 |
devlog/three_threads.nim | 0 | 1 | 0 | 0 | 0 | 0 |
devlog/index.nim | 1 | 0 | 0 | 0 | 0 | 0 |
| theme and helpers | ||||||
quaderno.nim | 2 | 0 | 1 | 1 | 0 | 22 |
munari.nim | 0 | 0 | 0 | 2 | 0 | 7 |
parti.nim | 0 | 0 | 1 | 0 | 1 | 8 |
blocchi.nim | 0 | 0 | 0 | 0 | 0 | 0 |
Counted in the sources on 8 November 2026; snapshot in devlog/data/blocks-review/audit.tsv. The theme and its helpers may hold CSS: that is their job. style= counts inline styles. | ||||||
Three kinds of drift show up:
- Page furniture written by hand. The kicker and lede at the top of nearly every page, the cards of the home page and the devlog, the galleries of three posts: the same HTML, copied.
- Styles and scripts per page. 8 pages carry a
<style>block, and some carry a script, so a component looks slightly different on each page and can't be fixed in one place. - Colours where they are used. Hex values in pages and in table options, outside the palette (the design review counts the colours; here they are counted with everything else).
The new pages of this week's restructure (the Design Ref and the design review) are among the worst: they were written fast, with HTML, which is the drift this post is about.
The blocks that would replace it
Each recurring piece of HTML becomes a block with a name that says what it is. Here they are, from the simplest to the most complex, with where they are used today:
| Blocks for tabelline's pages | |||
|---|---|---|---|
| proposed names; nbIndice and nbTabs exist | |||
| what it shows | how it is done today | where | |
nbTitolo(kicker, title, lede) | the top of a page: what it is, its title, one paragraph | <p class="kicker">, # title, <p class="lede"> by hand | 17 pages |
nbNota(text, kind) | a note with a meaning: info, done, missing, warning (with the triangle) | nbNota(text, color) with a colour name | 6 pages |
nbCards: nbCard(title, href, text) | a grid of cards that link to pages | <div class="cards"> and notes by hand | home, devlog, Design Ref |
nbIndice | the table of contents | a block already | most pages |
nbTabs(python, r): body | the same example in Nim, Python and R | a template that renders blocks into a string | explainer, posts, book |
nbShowCode: body | tables with their code folded below | new in the Milano Cortina post | 1 post |
nbBeside: body | small tables side by side | <div class="affiancate"> inside a gallery card | 1 post |
nbGalleria(label): nbScheda(title): body | a row of cards to swipe, each any blocks | a hand-made template with nb.blocks.setLen and HTML strings, per post | 4 pages |
nbTinte(tokens) | colour swatches with names and uses | <ul> of swatches with inline styles | palettes, Design Ref, design review |
nbParti(t) | a table with a button that shows its parts | HTML, a button and a script on the home page | home |
nbSpecs, nbPaletteSwitch, nbGrid | the few interactive pieces: the specs filter, the palette picker, the tabellone grid | <script> in the page | 3 pages |
A first block, working
nimib makes a block with newNbBlock: a type with its fields and a toHtml that renders it. A
block that holds other blocks inherits from NbContainer, and nb.withContainer collects what
its body adds. So a gallery is two small blocks and two templates, in docs/blocchi.nim (the
name is provisional):
import std/strformat
import nimib
newNbBlock(NbGalleria of NbContainer):
label: string
toHtml:
&"""<div class="nb-galleria" tabindex="0" aria-label="{blk.label}">""" & nbContainerToHtml(blk, nb) & "</div>"
newNbBlock(NbScheda of NbContainer):
title: string
toHtml:
&"""<div class="nb-scheda"><h3>{blk.title}</h3>""" & nbContainerToHtml(blk, nb) & "</div>"
template nbGalleria*(what: string, body: untyped) =
## A row of cards to swipe sideways; `what` says what they are, for screen readers.
let galleria = newNbGalleria(label = what)
nb.withContainer(galleria):
body
nb.add galleria
template nbScheda*(heading: string, body: untyped) =
## One card of a gallery: a heading, then any blocks (text, code, tables). Cards are numbered
## by the theme.
let scheda = newNbScheda(title = heading)
nb.withContainer(scheda):
body
nb.add scheda
Here it is in use. The cards hold ordinary blocks: text, code that runs, a table. The page says a gallery of cards, not how one is drawn:
Text
A card holds any blocks. This one holds only text, written in Markdown.
Code
Code runs where it is, and its output follows it.
echo 6 * 7
42
A table
And a table made with tabelline.
| risultato | |
|---|---|
| 2 × 3 | 6 |
| 4 × 5 | 20 |
| 6 × 7 | 42 |
The gallery of Designing tabelline 0.1 does the same with a 25-line template that renders blocks
into a string of HTML, cuts them off the page (nb.blocks.setLen) and pastes the string back with
nbRawHtml; each post that wanted a gallery copied its CSS too. With the block, the CSS is in the
theme once, the cards are numbered by it, and the blocks inside stay blocks (a Markdown backend
could render them too).
Where things should live
Three places, and a page uses them without knowing what is inside:
- A style module (
docs/stile.nim, say): every styling decision. The tokens of the design review as Nim constants, the CSS of both looks generated from them, the fonts. No colour and no CSS anywhere else, so changing a colour is one line. - A blocks module (
docs/blocchi.nim, ormy.nimas in your earlier projects): every custom block of the pages, each documented. Pagesimportit and use blocks only. - Data modules, as today (
piano.nim,mese.nim): what a page shows, kept apart from how.
docs/quaderno.nim today mixes all three (the CSS, the blocks nbIndice, nbTabs, nbNota,
and the header): it would split into the first two. nbRawHtml stays for a true one-off, with a
comment that says why it is not a block.
Tables are the exception that proves the rule: they already are a block (nbTable), but their
colours come from optQuaderno() and from hex values in tabStyle. A table preset that reads the
tokens (the design review's choice 5) puts their colours in the style module too.
The rules
For AGENTS.md, and for whoever writes the next page:
- A page uses blocks. Markdown in
nbText, nimib's blocks,nbTable, and the project's custom blocks. No HTML tags innbText. - Repeated HTML becomes a block in the blocks module, the second time it is needed, not the third.
- No styles or colours in a page. CSS and colours live in the style module; a page that needs a new look for something needs a new block, or a new token.
nbRawHtmlis a last resort, for a one-off, with a comment saying why.- CI counts the drift. The audit above becomes a check (
tools/drift.nim) that fails when a page adds HTML, a<style>or a colour outside the allowed list.
A nimib skill against drift
Most of these pages were written by agents, quickly, and an agent reaches for HTML because it knows HTML better than it knows nimib's block API. A nimib skill should change that default. What it should say:
- The decision, in order: is there a nimib block for it? Is there one in the project's blocks
module? If it will be needed again, make one with
newNbBlock; only thennbRawHtml. - How a block is made, with two short templates to copy: a leaf block (fields,
toHtml) and a container block (of NbContainer,withContainer), like the gallery above. - Where its CSS goes: the style module, using tokens, never a hex value.
- A check to run: a small script, like this page's audit, that lists HTML in
nbText,nbRawHtmlcalls,<style>blocks and hex colours, so the agent sees its own drift before a PR. - Evals: tasks such as "add a warning note", "add a gallery of three tables", "add a page of cards", graded on whether the result uses blocks and adds no raw HTML or colour.
The skill would start in your personal skills repository, as you suggest, and move to nimib (or a nimib-land repository) once it has proved itself. The earlier nimib skills (closed nimib#264) have a custom blocks reference to start from.
Choices to make
- Names. Blocks module
blocchi.nim(Italian likequaderno,piano,parti) ormy.nim; style modulestile.nimortema.nim. Recommended:blocchi.nimandstile.nim. - The theme files.
quaderno.nimandmunari.nimfold intostile.nim(both looks) andblocchi.nim(header, footer, blocks), or stay as they are with only the new modules added. Recommended: fold them: one place each for style and blocks. - Posts. Dated posts keep their words, but their code is migrated to blocks too, or they are left as they were written. Recommended: migrate: the code is not the post, and a post left with its own CSS breaks when the theme changes.
- The CI check. Fails on new drift (with an allow list for the theme), or only reports. Recommended: fail, once the migration is done.
What happens next
One PR, after this post and the design review are agreed: the style module with the tokens, the
blocks module with the blocks above, every page moved to them (the living documents first, then
the posts), the table preset, the drift check in CI, the rules in AGENTS.md, and the Design Ref
rewritten around the blocks: for each block, what it shows, when to use it, and how it looks in
both looks. The skill is drafted alongside, in your skills repository.
How it is built
The audit read every .nim file under docs/ and counted, per file: calls of nbRawHtml;
nbText blocks whose triple-quoted text holds an HTML tag (<div, <p, <span, <a href, …);
<style and <script; inline style="; and distinct #RRGGBB values. Files are grouped as
living documents, posts, or theme and helpers (where CSS belongs); data modules are left out. It
ran once and was saved as docs/devlog/data/blocks-review/audit.tsv: the post is dated, so its
numbers stay those of 8 November 2026 while the pages are migrated (the live count will be a
check in CI, tools/drift.nim, that reads the pages every time). The
code of docs/blocchi.nim above is the module as it was on 8 November 2026, kept in
docs/devlog/data/blocks-review/blocchi.nim: the blocks module has grown since, and the gallery
is drawn with the same two blocks.