---
title: Code, tables and notes
date: 2026-02-16
updated: 2026-09-03
authors: [you, coauthor]
category: Tutorials
tags: [guide, code]
summary: Syntax highlighting without a vendored theme, scrolling tables, footnotes, GitHub-style alerts, and what multiple authors look like.
doi: 10.5281/zenodo.123
featured: true
featuredSection: true
---

Fenced code is highlighted at build time by highlight.js. The token colours are
defined against the site's CSS variables rather than copied from a vendor
theme, so light and dark stay consistent with everything else on the page.

```python
import numpy as np

def bootstrap_se(sample, statistic, replicates=2000, seed=0):
    """Standard error of `statistic` under resampling with replacement."""
    rng = np.random.default_rng(seed)
    draws = rng.choice(sample, size=(replicates, sample.size), replace=True)
    return np.std([statistic(row) for row in draws], ddof=1)
```

Caption: The bootstrap standard error, resampling with replacement. Listings
are numbered in their own sequence, and their captions go above them.

```r
fit <- lm(mpg ~ wt + factor(cyl), data = mtcars)
summary(fit)$coefficients[, c("Estimate", "Std. Error")]
```

The language and the copy button sit in a bar above each block, and every line
is numbered. The numbers come from a CSS counter, so copying the block gives
the code and nothing else. An unknown language is left unhighlighted rather
than guessed at, because a wrong guess colours the wrong tokens and reads worse
than plain text.

## Figures

An image on its own line becomes a figure. The quoted title after the path is
the caption:

![The four build stages](https://blog.kiarashs.ir/figures/pipeline.svg "Markdown goes in, a directory of HTML comes out.")

The build reads the file to set `width` and `height`, so the page does not
reflow as figures load, and adds `loading="lazy"`. Put images in `public/`
and reference them from the root, as above; the deployment's base path is
added at build time. If a `name.dark.ext` sibling exists — as it does here —
it is used when the reader is on the dark theme, which saves white-background
plots from glaring out of a dark page.

## Video

An image whose path is a video is a player instead, numbered and captioned like
any other figure:

```markdown
![A run of the sampler](/posts/my-post/clip.mp4)

Caption: Ten seconds at the start, sped up.
```

A YouTube link works the same way:

```markdown
![The talk](https://youtu.be/dQw4w9WgXcQ)
```

Nothing is asked of YouTube until the reader clicks: the build draws the
video's own still with a play badge over it, and the player replaces it on the
click. With JavaScript off the still is a link to the video on YouTube. The
embed goes to `youtube-nocookie.com`, and a `?t=` in the link you paste is kept,
so a link copied at a particular moment starts there.

Raw `<video>` HTML on its own line still works if you want the attributes.

## Captions

Any block can be captioned by following it with a paragraph that starts with
`Caption:`. Figures, tables, listings and notebooks are each numbered in their
own sequence, the way a paper numbers them, and the numbering is done at build
time so it survives with JavaScript off. Images can use the Markdown title
instead, which comes to the same thing. A caption sits below a figure and above
anything read from the top down: a table, a listing, a notebook.

## Tables

Wide tables scroll inside their own box instead of pushing the page sideways.
A table's caption goes above it, as in a journal.

| Stage | What it does |
| --- | --- |
| `render-diagrams` | Mermaid to SVG, light and dark |
| `tsc --noEmit` | Type-checks the code |
| `vite build` | Client bundle |
| `vite build --ssr` | Server bundle |
| `render-cards` | A social-card image for each post |
| `render-avatar` | The front page's portrait, resized |
| `prerender` | One HTML file per route, plus feeds and sitemap |

Caption: The seven stages of `npm run build`, in the order they run.

## Notebooks

A fence tagged `notebook` whose body is a path under `public/` embeds the
notebook: markdown cells become prose, code cells keep their execution counts,
and outputs come through — text, tables, images and errors alike.

````markdown
```notebook
/posts/code-tables-and-notes/sampling.ipynb
```
````

Which gives, with `#invert` after the path so the plot's white paper turns
dark on the dark theme, as `#invert` does for a figure:

[sampling.ipynb](https://blog.kiarashs.ir/posts/code-tables-and-notes/sampling.ipynb)

Caption: A notebook rendered into the post. The `.ipynb` stays in `public/`, so
readers can download the original.

The notebook is read at build time, so nothing about Jupyter reaches the
browser: no widgets, no kernel, no JavaScript beyond what the rest of the page
already loads.

## Footnotes and lists

Footnotes collect at the foot of the post with a link back to where they were
referenced.[^pipeline] Task lists render as checkboxes:

- [x] Prerendered HTML for every route
- [x] Feed and sitemap
- [ ] Whatever you add next

[^pipeline]: The pipeline is remark-parse, remark-gfm, the emoji step,
    remark-math, remark-rehype, then rehype-raw, rehype-slug, the alert step,
    rehype-citation, the notebook and diagram steps, rehype-highlight, equation
    numbering, rehype-katex and finally the figure and caption steps. Order
    matters: raw HTML is parsed first, notebooks and diagrams are expanded
    before the highlighter sees them, and captions are numbered last, once
    every block that can take one exists.

## Inline formatting

The usual emphasis works, **bold**, *italic* and ***both***, and so does
~~struck-out text~~, set quieter than the sentence around it. HTML fills in
where Markdown has no syntax: <mark>a highlight</mark>, a key such as
<kbd>Ctrl</kbd>+<kbd>C</kbd>, H<sub>2</sub>O and x<sup>2</sup>.

A colour written as inline code gets a swatch of itself: `#c0573e`,
`rgb(46 125 50)`, `hsl(210, 60%, 45%)`, and a translucent one, `#1565c080`,
over a checkerboard. Only a code span holding the colour and nothing else
counts, so `color: #c0573e` stays as written.

### Another typeface

Two other faces can set a passage: EB Garamond, a revival of the sixteenth-century
roman of Claude Garamond, and Libertinus Serif, the maintained fork of Linux
Libertine, which ACM's paper template is set in. Put `font=` on any HTML
element, with blank lines inside a block so Markdown keeps working:

```html
<div font="garamond">

A passage in EB Garamond, with *italic*, **bold** and the figures 1625.

</div>
```

<div font="garamond">

A passage in EB Garamond, with *italic*, **bold** and the figures 1625. The
face is scaled to sit beside the text around it, so the passage changes its
letters and not its size. Code stays `monospace` and maths stays $e^{i\pi}$.

</div>

<div font="libertinus">

The same in Libertinus Serif, with *italic*, **bold** and the figures 1625.
It is narrower than the body face and looks like the page of a paper.

</div>

Inline, `<span font="libertinus">a few words</span>` sets
<span font="libertinus">a few words</span> in it. `font: garamond` in the
frontmatter sets a whole post, title included. A name the site does not have
leaves the text in the body face, and the build says which names it has. A
face is downloaded only by a page that uses it.

### Definitions and abbreviations

A term on its line and its definition on the next, after a colon, make a
definition list:

```markdown
Prior
: What you believe about a parameter before seeing the data.

Likelihood
: How probable the data are, for each value the parameter could take.

Posterior
Updated belief
: The prior, reweighted by the likelihood: what the data leave you believing.
```

Prior
: What you believe about a parameter before seeing the data.

Likelihood
: How probable the data are, for each value the parameter could take.

Posterior
Updated belief
: The prior, reweighted by the likelihood: what the data leave you believing.

Two terms in a row share the definition after them, as the last pair does.
`<dl>`, `<dt>` and `<dd>` written as HTML come out the same.

An abbreviation is defined once, on a line of its own anywhere in the post:

```markdown
*[MCMC]: Markov chain Monte Carlo
```

The line is not shown, and every MCMC after it is marked, with the full name
when the pointer rests on it. A phone has no pointer to rest, so the first use
is spelled out where it stands, as on paper: a sampler built on MCMC draws from
the posterior, and every later MCMC is marked but not spelled out again.

### Collapsible sections

<details>
<summary>A collapsible section</summary>

Write it in HTML, with a blank line after the `<summary>` and another before
`</details>`, and Markdown works inside: **bold**, a list, a code block.

<details>
<summary>One inside it</summary>

A section inside another is a box inside the first, so the nesting shows.

</details>

</details>

## Emoji

GitHub's shortcodes work, in prose and in the frontmatter both: `:rocket:` is
🚀, `:+1:` is 👍, and the names are the ones GitHub publishes, all 1,913 of
them. They are resolved when the post is compiled, so the table of names never
reaches a reader's browser and the character in the HTML is the character they
get.

A shortcode inside `code` or a fence is left alone, which is why this paragraph
can print one. Two things worth knowing: a pair of colons around a name nothing
recognises stays exactly as written, so `12:30:45` and a `Note:` at the start of
a line are safe; and the very short names are real, so `:x:` is ❌ rather than a
letter between colons.

## Mermaid

```mermaid
classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am I?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
```

## Alerts

GitHub's alert syntax works here. A blockquote whose first line is one of five
markers becomes a callout:

```markdown
> [!NOTE]
> **Key Takeaway:** Self-supervised learning can reduce the need for labelled
> IMU data.
```

> [!NOTE]
> **Key Takeaway:** Self-supervised learning can reduce the need for labelled IMU data.

> [!TIP]
> Helpful advice for doing something better or more easily.

> [!IMPORTANT]
> Essential information needed to succeed.

> [!WARNING]
> Something that could cause problems if ignored.

> [!CAUTION]
> Describes potential negative consequences.

The marker is matched case-insensitively, and an alert holds whatever a
blockquote holds — several paragraphs, a list, a code fence, a citation. Any
blockquote without one of the five markers stays a blockquote, because a
quotation is still a quotation.

The reason to borrow GitHub's syntax rather than invent one is that it degrades
into something readable. Paste the source into a plain Markdown viewer, or read
it as a diff, and you still get a blockquote with its label on the first line.
Nothing is lost but the colour.

## Several authors

This post lists two. Each gets a byline with their affiliation at the top, a
card at the bottom, and their own page listing everything they have written.

## Abbreviations

- **MCMC**: Markov chain Monte Carlo
