Code
Code sits in a black exhibit panel. Comments are mustard, so the explanation reads before the syntax.
Stable Class names and props are not expected to change before 1.0.
In this chapter 15 pages
Code panels
# one step of message passing on a simplicial complex
def step(x, boundary, weight):
up = boundary.T @ (boundary @ x) # neighbors through shared cofaces
down = boundary @ (boundary.T @ x) # neighbors through shared faces
return torch.relu((x + up + down) @ weight)
for epoch in range(200):
loss = F.cross_entropy(model(x), y)<Code lang="python" title="train.py" code={source} />| Prop | Effect | Default |
|---|---|---|
code | The source text | |
lang | Language for highlighting | txt |
title | Shown in the bar; defaults to the language | |
copy | Show the copy button | true |
wrap | Wrap long lines instead of scrolling them, each under its own indent, or under the value of a key = value line | false |
A block with a line wider than its panel scrolls sideways, and takes focus so a keyboard can scroll it; one whose lines fit never becomes a tab stop. js/scroll.js keeps that up to date as the page changes width.
In plain HTML, wrap a <pre> in .ply-code and add a .ply-code__bar with a [data-ply-copy] button; copy.js handles the click. Spans with classes c, k, s, and n color comments, keywords, strings, and numbers if you highlight by hand.
Inline code and keys
Inline code like torch.sparse.mm sits on the wall gray. Keys look like this: Ctrl + K.
The highlighting theme
The panel colors are also a TextMate theme at dist/code-theme.json, for Shiki, Astro's Markdown, and VS Code. See Other targets.