Code
Code should feel at home on a page of writing. It has its own rhythm: indentation takes the place of some punctuation, a blank line separates thoughts, and a name may carry an idea through several sentences. These examples are here to look at, rather than to assemble into a single program. Read them at a wide measure, then narrow the window and see how the page holds together.
Inside a sentence
A name like paragraphWidth should be distinct without becoming a badge. Calling measure(text) is part of the sentence, as is checking whether width > 0. The surrounding type should not jump or grow a taller line just because a few words have changed their clothes.
Inline code can sit beside strong emphasis, an aside, or a link to the layout reference. A path such as src/components/TypesetProse.astro is a useful longer example; a_deliberately_long_identifier_that_should_wrap_without_widening_the_page tests what happens when there is no convenient space.
One line, then a paragraph
Sometimes the entire example is a single expression. It needs a little separation from the discussion, not an editor window of its own.
const total = prices.reduce((sum, price) => sum + price, 0);
The result matters less here than the transition back into prose. The code block stays within the same column as this paragraph, with a little padding inside its background. The spacing above and below follows the ordinary rhythm of the page.
JavaScript and TypeScript
A small function brings together punctuation, indentation, strings, and a comment. Syntax colors help distinguish these parts without changing the shape or spacing of the program.
function describeBook({ title, author, year }) {
// Keep the title intact, including its punctuation.
const credit = author ? `by ${author}` : "Anonymous";
return `${title} (${year}), ${credit}`;
}
console.log(
describeBook({
title: "A Room of One’s Own",
author: "Virginia Woolf",
year: 1929,
}),
);
TypeScript puts a different density on the page. Angle brackets, unions, and optional properties should not need a larger font or a darker box to be understood.
type Result<T> =
| { ok: true; value: T }
| { ok: false; error: string };
function first<T>(items: readonly T[]): Result<T> {
const value = items[0];
return value === undefined
? { ok: false, error: "The shelf is empty." }
: { ok: true, value };
}
Python
In Python, leading whitespace is part of the meaning. This longer listing mixes imports, a small data structure, a comprehension, and a loop. Blank lines should survive exactly as written.
from dataclasses import dataclass
from pathlib import Path
@dataclass(frozen=True)
class Note:
title: str
words: int
def read_notes(directory: Path) -> list[Note]:
notes = []
for path in sorted(directory.glob("*.md")):
text = path.read_text(encoding="utf-8")
title = text.splitlines()[0].removeprefix("# ")
notes.append(Note(title, len(text.split())))
return notes
notes = read_notes(Path("notes"))
long_reads = [note for note in notes if note.words > 1000]
for note in long_reads:
print(f"{note.title}: {note.words:,} words")
A longer block should still feel like a passage in the article. There is no filename bar or row of buttons to cross before the writing begins again.
OCaml
Pattern matching produces a less rectangular silhouette. A few short branches can be easier to read than a paragraph explaining every possibility.
type tree =
| Leaf
| Node of tree * int * tree
let rec sum = function
| Leaf -> 0
| Node (left, value, right) ->
sum left + value + sum right
let rec map f = function
| Leaf -> Leaf
| Node (left, value, right) ->
Node (map f left, f value, map f right)
Rust and Go
The same page needs to accommodate languages with different habits. Rust’s lifetimes and iterator chains create one texture; Go’s short declarations and explicit errors create another.
fn longest<'a>(words: &'a [&'a str]) -> Option<&'a str> {
words.iter().copied().max_by_key(|word| word.len())
}
fn main() {
let words = ["paper", "paragraph", "ink"];
if let Some(word) = longest(&words) {
println!("Longest word: {word}");
}
}
func readTitle(path string) (string, error) {
data, err := os.ReadFile(path)
if err != nil {
return "", err
}
title, _, _ := strings.Cut(string(data), "\n")
return strings.TrimPrefix(title, "# "), nil
}
Those two listings are deliberately adjacent. Their backgrounds should distinguish the blocks without turning them into a stack of cards.
C
A pointer, a loop, and a few carefully placed spaces are enough for another kind of example. The font needs to distinguish braces from parentheses and a zero from the letter O.
#include <stddef.h>
size_t count_lines(const char *text) {
size_t lines = 0;
for (const char *p = text; *p != '\0'; ++p) {
if (*p == '\n') {
++lines;
}
}
return lines;
}
Queries and commands
SQL reads almost like a list of instructions. Uppercase keywords are already a visual distinction; they do not necessarily need their own color.
SELECT author, COUNT(*) AS books_read
FROM reading_log
WHERE finished_at >= DATE '2026-01-01'
GROUP BY author
HAVING COUNT(*) > 1
ORDER BY books_read DESC, author;
A shell pipeline is another sort of sentence. Here the line breaks are explicit, and the backslashes belong to the example rather than to the page’s wrapping rules.
find ./notes -name '*.md' -print0 \
| xargs -0 wc -w \
| sort -n
The output has no language attached. Columns and blank lines are still meaningful, so plain fenced text receives the same treatment as highlighted source.
184 ./notes/margins.md
392 ./notes/paragraphs.md
817 ./notes/reading.md
1393 total
Data rather than instructions
JSON is dense with repeated punctuation. YAML uses indentation instead. Both should be quiet enough to read alongside an explanation.
{
"title": "Notes on reading",
"published": true,
"tags": ["books", "typography"],
"layout": {
"measure": 640,
"insets": false
}
}
The nested structure is the interesting part of this next example. A reader should be able to trace it without depending on colored keys.
title: Notes on reading
published: true
tags:
- books
- typography
layout:
measure: 640
insets: false
Markup and styles
HTML and CSS make a useful pair because they describe both structure and appearance. These are examples to read; the markup is not rendered as part of the page.
<figure>
<img src="/images/hills.svg" alt="Green hills at dawn" />
<figcaption>A little light before the day begins.</figcaption>
</figure>
.reading-room {
max-width: 40rem;
margin-inline: auto;
color: #292524;
}
.reading-room > * + * {
margin-block-start: 1.75rem;
}
Code inside a list
-
Start with a small input. This listing belongs to the list item, so its left edge follows the item’s text rather than the outside edge of the article.
words = ["a", "small", "design"]The explanation continues inside the same item. A code block should not make the number or the indentation disappear.
-
Transform the input and inspect the result.
print(" ".join(words)) -
Return to the surrounding discussion, with inline
codewhere it helps.
Code inside a quotation
A quoted explanation can contain a program as well as prose. The code should remain upright monospace even when the surrounding quotation is italic.
const quiet = noise.filter((sound) => sound.volume < 2);The quotation then continues in its own voice, without changing the indentation of the rest of the article.
Outside the quotation, the writing returns to the full measure. Nested examples should inherit their context without acquiring a second set of decorative frames.
Changes and long lines
A diff uses color to distinguish additions from removals. Its plus and minus signs carry the same meaning, so color is not the only way to read a change.
- const width = 480;
+ const width = container.clientWidth;
const lines = compose(words, width);
The next listing deliberately contains a line wider than the reading column. On screen it should scroll horizontally inside its own background, not force the entire page sideways or shrink the type. In print, it should wrap instead of losing the end of the line.
const message =
"This deliberately long line keeps going beyond the ordinary reading measure so that horizontal scrolling, selection, and the right edge of the code background can all be checked in one place.";
console.log(message);
Punctuation, symbols, and the return to prose
Literal angle brackets, ampersands, quotation marks, and non-ASCII text should survive rendering and copying. The last example combines them without asking the page to interpret them as HTML.
0 O o 1 I l {} [] () < > &
"double quotes" 'single quotes' `backticks`
café · naïve · λ · → · 日本語
<div>This is text, not an element.</div>
And then the article is simply an article again. The point of the treatment is not to hide the code, but to let it participate in the same reading experience: another passage of text, with a different alphabet of habits and a little extra space around it.