Skip to content

~/styleguide

Markdown style guide

What a post can contain. Write any of this in a GitHub issue and it renders exactly like this.

Everything below is plain markdown — the same thing you'd type into a GitHub issue. Open this file (content/styleguide.md) next to the rendered page to see the source for each feature.

Text#

Paragraphs, bold, italic, strikethrough, inline code, and links. Inline code can be highlighted too: const x: number = 42. Emoji shortcodes work 🚀 🎉. Keys: ⌘ + K.

GitHub references are linked automatically: #3, @nnamanikester.

Lists#

  • Unordered lists
  • With nesting
    • like this
  • and task lists
  • that render as checkboxes
  1. Ordered lists
  2. Use mono numerals

A plain blockquote, for when someone else said it better.

Alerts#

Code#

A fenced block with a language gets a header with the language name, a copy button, and a wrap toggle. Add title="…" for a filename, showLineNumbers for numbers, and {1,3-4} to highlight lines.

TypeScriptlib/retry.ts
export async function retry<T>(fn: () => Promise<T>, attempts = 3): Promise<T> {
  let lastError: unknown;
  for (let i = 0; i < attempts; i++) {
    try {
      return await fn();
    } catch (err) {
      lastError = err;
      await new Promise((r) => setTimeout(r, 2 ** i * 100));
    }
  }
  throw lastError;
}

Highlight words with /word/ in the meta:

Python
def split(source: str, size: int = 512) -> list[str]:
    chunk = []
    return [source[i : i + size] for i in range(0, len(source), size)]

Inline notation comments for diffs, focus, highlights and errors:

TSXButton.tsx
export function Button({ label }: Props) {
  const color = "gray"; 
  const color = useTheme().accent; 
  return <button style={{ color }}>{label}</button>; 
}
JavaScript
const res = await fetch("/api/posts"); 
const posts = await res.json(); 
console.log(posts.length);
JavaScript
const unused = 1; 
JSON.parse("{"); 

Tabs#

Group blocks with :::code-group. The reader's choice is remembered across every group on the site.

const sum = (a: number, b: number): number => a + b;

Shell blocks tagged npm2yarn become npm / pnpm / yarn / bun tabs automatically:

npm install -D vitest

Long blocks (over 28 lines) collapse with a "show all" button.

Tables#

ApproachQualitySpeedNotes
By fileLowFastChunks too big for context
Fixed tokensMidFastSplits functions mid-way
AST (tree-sitter)HighSlowBest boundaries, more code

Maths#

Inline E=mc2E = mc^2 and display:

softmax(xi)=exi∑jexj\text{softmax}(x_i) = \frac{e^{x_i}}{\sum_{j} e^{x_j}}

Diagrams#

Media#

A placeholder image with a caption
Captions come from the image title.

Embeds — a YouTube or X link alone on a line, or the swyxkit shortcodes:

Details and footnotes#

Raw HTML works in posts

So you can fold long asides away, with markdown inside.

Footnotes are collected at the bottom1, with links back2.

Footnotes#

  1. Like this one. ↩

  2. GitHub-flavoured markdown supports them natively. ↩