What does teletext do?
You build screens the way teletext and Minitel services did. Everything sits on a grid of 40 columns and 25 rows. Each cell holds one character or one mosaic block, with one foreground and one background colour out of 8. Pictures are drawn with blocks of 2 × 3 dots.
assets/teletext.js does the drawing: a canvas with the teletext font, character rounding, mosaics, double sizes,
flashing, concealed text, a live header and clock, page search, subpages and keyboard navigation. Your job is the
content and the layout, through its Page API.
Workflow
- Frame the service. Decide:
- A service name: capitals, up to 10 characters, invented unless it is the user's own.
- The pages: numbers from 100 to 899, with 100 as the index.
- The mode:
minitelwhen the user says Minitel or videotex, or wants the page drawn character by character at 1,200 baud;teletextotherwise.
- Sketch each page on the grid before writing code. Put a 40-column mock-up in a comment above the page: the
title band, the content rows and the link row. Count the characters: a row holds 40, and a double-width or
double-size character takes 2. The layouts in
references/page-design.mdare a good starting point. - Read the closest worked example, then start from the template. The five examples in
assets/examples/(listed inreferences/gallery.md) cover a weather map, a club service, a Minitel 404 page, a game and TV listings. Copyassets/templates/service.htmlandassets/teletext.jsinto the working folder, then replace the example pages. For a single screen, keep one page and calltv.show(page)instead oftv.service(...). - Write the pages with the API summarised below. All of it is in
references/api.md. - Draw the pictures in blocks.
blocks()takes ASCII art at block resolution: 2 characters across and 3 lines down per cell. Readreferences/mosaics.mdbefore drawing anything bigger than an icon. - Check your work:
- Run
node <skill>/scripts/shot.mjs page.html shot.png --keys 101(it needs Playwright) and look at the screenshot. - Fix every warning it prints. They come from
page.lint(): cut text, mixed colours in a block, poor contrast, missing glyphs. - Repeat until there are no warnings.
- Without a browser,
require()the library in Node and printpage.lint()for each page.
- Run
- Deliver one file.
node <skill>/scripts/inline.mjs page.htmlputs the library in place of the<script src="teletext.js">tag. The page then opens with a double click, with no other file and no network. - Film it, if a GIF or video is wanted:
node <skill>/scripts/capture.mjs page.html out.gif --seconds 8. Add--do "2000 type 102"to drive the page and--mp4 out.mp4for a video. It needs ffmpeg.
The grid
- Row 0 is the header.
page.header(number, 'SERVICE')draws the page number, the service name, the date and a live clock; in Minitel mode, the service row instead. Do not write on row 0 yourself when you use it. - Rows 1 to 23 hold the content. Row 24 is for
fastext(): four links in red, green, yellow and cyan, like the coloured keys of a remote control. - Text never wraps. Plan the line breaks with
\n: the next line starts at the same column. Text that runs past column 39 is cut, andlint()reports it. - One foreground and one background colour per cell. Backgrounds come from
fill()or from thebgof text and blocks, and they persist: text written withoutbgkeeps the background already in each cell. - Sizes:
double-heighttakes the given row and the row below;double-widthtakes 2 columns;double-sizetakes both. - The 8 colours are the only ones: black, red, green, yellow, blue, magenta, cyan, white. No other colour, font, gradient, image or blur goes on the screen.
- The whole screen is 80 × 75 blocks when you draw in mosaics.
The look
-
Colours: a black background and bright text. White for body text and numbers, cyan for labels, yellow for headings and highlights, green for prompts. Use red and magenta sparingly.
-
Headings: a coloured title band (
fillrows 1 to 3, then a double-height title), or a big mosaic word made withbanner()on the index page. -
Text: short lines and plain words, with headings in capitals.
-
Lists of pages: the page number in white, on the right of each line.
-
Figures: tables aligned in columns, with numbers right-aligned by
right(). -
Pictures: small icons, maps, logos and charts in blocks. Draw maps from coordinates with
Teletext.polygonArt(). Usebar()for bar charts and separated blocks (separated: true) for a lighter texture. -
Motion comes only from teletext's own means:
- a flashing word or two (
flash: true); - the live clock;
- the header counting through page numbers while it searches;
- subpages that rotate every 8 seconds (
{ 200: [pageA, pageB] }); - in Minitel mode, the page drawn character by character.
No CSS animation, scrolling or smooth transition.
- a flashing word or two (
-
Hidden answers:
conceal: truehides text until the reader presses?. It suits quizzes, puzzles and spoilers.
API summary
const page = Teletext.page() // 40 x 25, black
.header(100, 'SERVICE') // row 0: page number, name, date, clock
.fill(1, 0, 3, 40, { bg: 'blue' }) // rectangle of background
.text(2, 1, 'WEATHER', { size: 'double-height', fg: 'yellow', bg: 'blue' })
.text(5, 1, 'Line one\nline two', { fg: 'white' }) // never wraps; \n keeps the column
.center(7, 'CENTRED', { fg: 'cyan' })
.right(9, '102', { fg: 'white' }, 2) // ends 2 columns from the edge
.banner(11, 2, 'NEWS', { fg: 'yellow' }) // big letters in blocks: 3 columns x 3 rows each
// ({ scale: 2 }: smooth, 6 columns x 5 rows each)
.blocks(15, 2, ['.##.', '####', '.##.'], { fg: 'red' }) // ASCII art, 2 x 3 per cell
.bar(19, 2, 30, 0.6, { fg: 'green' }) // 60 % of 30 cells, to half a cell
.text(21, 1, 'Answer: 42', { conceal: true }) // shown when the reader presses ?
.text(23, 1, ' Index ', { inverse: true }) // black on white
.fastext([{ label: 'Index', page: 100 }, { label: 'News', page: 101 }, 'Sport', 'Help']);
page.lint(); // problems to fix, as sentences
page.toText(); // the page as 25 lines of plain text
const tv = Teletext.screen('#tv', { mode: 'teletext', keys: true, label: 'My service' });
tv.service({ 100: index, 101: news, 200: [sportA, sportB] }, { start: 100 }); // or tv.show(page)
// Maps: fill a polygon of [longitude, latitude] points, then place labels with project().
const map = Teletext.polygonArt(OUTLINE, { width: 22, latitude: true });
page.blocks(5, 25, map.art, { fg: 'green' });
// Games and animation: a new page every frame, repainted without announcing.
setInterval(() => tv.draw(buildFrame()), 40);
tv.announce('Game over. Score 120');
Style options for text, center and right: fg, bg, size (normal, double-height, double-width,
double-size), flash, conceal. For blocks, mosaic and bar: fg, bg, separated, flash, and colors
for blocks ({ '#': 'yellow', r: 'red' }). Screen options: mode, palette (color or grey), crt, smooth,
baud, fit, keys, label, now, onPage. Screen methods: show, service, goto, draw, announce,
setPalette, toggleReveal, destroy.
Accessibility
- Screen readers: the library mirrors each page as text in a live region and hides the canvas.
- Keyboard: the screen takes focus and keyboard input; with
keys: trueit listens on the whole window. - Labels and help: give the screen a
label, and keep a short line of help under it that explains the keys. The template has one. - Reduced motion:
prefers-reduced-motionturns off flashing, the page search and the progressive drawing. - Colour: never let colour alone carry meaning. Write the word too (
UP 2%, not a green arrow alone).
Do not
- Imitate a real service or brand: no broadcaster names, logos, page layouts or slogans (BBC Ceefax, ITV ORACLE, Teletext Ltd, the Minitel or 3615 logos, France Télécom or Orange). Invent the service.
- Load anything from the network: no fonts, images or scripts, and no dependency to add.
- Edit
teletext.jsfor one page. If something is missing, build it in the page script withtext,blocksandmosaic. - Put two colours in one mosaic cell. Move the colour change to a cell boundary instead: every 2 blocks across or 3 blocks down.
Reference files
Read them when the task needs them.
references/api.md: every method and option, with the error messages and edge cases.references/page-design.md: layouts for an index, a news story, weather, a sports table, TV listings, a quiz, a 404 page and a live dashboard, with grid mock-ups.references/mosaics.md: how to draw with blocks (icons, maps, logos, charts, big type), the one-colour-per-cell rule, and how to plan colour changes.references/modes.md: teletext and Minitel, what is faithful and what is simplified, header formats, keys and timings.references/gallery.md: the five worked examples, their prompts and the patterns worth copying.