pdf-quiz-generator/docs/writing-articles.md
Daniel 158930d532
Some checks failed
Tests / backend (push) Failing after 5s
Tests / frontend (push) Successful in 28s
Tests / e2e (push) Failing after 36s
feat: section links in prose, a picker that writes them, and cards that render
**Cross-references can name a section.** `[[264#workup|the workup]]` opens the
reader at that heading, which is what a sentence about one part of a long
article actually means. Whole-article `[[264|label]]` is unchanged, and a
section renamed since is not a broken link — it lands at the top of the right
article, which is a mild disappointment rather than a dead end.

**A picker that writes the marker for you.** 🔗 Link an article, in the editor:
type a few words, click the article — or one of its sections — and the marker
is on the clipboard with the right title as its label. Getting an id used to
mean opening the library in another tab, finding the article and reading the
number out of the address bar, which is four steps and a chance to mistype,
every time. Its own small endpoint, because the listing deliberately does not
carry sections and this needs nothing else.

**Three things about cards that were built but never drawn:**

- A card can carry an image. The column is there, the API returns it, the
  editor accepts one — and no view in the app rendered it, so every picture
  anybody attached to a card was stored and never seen. Both card views show it
  now, small until clicked like every other figure.
- The deck browser printed `[[331|Epiglottitis]]` as brackets and a number. The
  study view has rendered them as links for a while; now both do.
- There was no way to make a deck by hand. Every deck came out of a model —
  generated from a document section or an article — so an educator who wanted
  to write six cards had nowhere to put them, and the add-a-card route could
  only add to a deck that did not exist yet. `+ New deck` on the cards page.

**Generate cards ran in silence.** It starts a real job, and the only place its
progress was drawn was inside the refine panel — which lives in the editor and
is shut. Pressing it on the reading page did nothing visible for ninety
seconds. It now says what it is doing where it was pressed.

**Overlays were invisible to learners.** A stored width is a fraction of the
image, and the stroke is drawn with `non-scaling-stroke`, which makes
`stroke-width` a count of screen pixels — so 0.006 meant six thousandths of a
pixel. The editor has always multiplied by its rendered width; the viewer now
does the same sum. Every region an educator has ever marked was invisible to
everyone who was not editing it.

Also: the figure viewer no longer scrolls, at any width, and the page behind it
is pinned properly (`overflow: hidden` on the body does nothing on iOS, so a
figure opened half-way down an article drifted while it was read). Options are
full width on a phone. The question toolbar's seven glyphs are four, with the
rest folded into the ⋯ that was already there, spelled out in words. The jobs
popover closes on a click anywhere outside it. And the editor has a way back to
Editorial — "back to the article", from an article you opened to edit, is a
loop.

The contract snapshot caught both new routes on the way through, which is what
it is for.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqXevQJhxFrM7jJg82cgZN
2026-09-13 02:05:02 +02:00

164 lines
8.3 KiB
Markdown

# Writing an article
Everything in an article body is Markdown, plus four pieces of syntax of our own.
None of them need the editor: they are plain text, so they survive copy-paste,
an AI draft, and a database import equally well.
## Cross-references — `[[…]]`
A link from one article to another. Three forms:
| You write | It renders as | Use when |
|---|---|---|
| `[[264\|respiratory failure]]` | a link labelled *respiratory failure* | **always, by preference** |
| `[[264#workup\|the workup]]` | the same, landing on that section | the sentence is about one part of a long article |
| `[[respiratory-failure]]` | a link labelled *respiratory-failure* | quick drafting |
The first number is the article's **id**, and the id is the part that cannot
change. A slug can be renamed — the old one keeps resolving, because every
former slug is kept in `article_slugs` — but an id is permanent, so the id form
is the one that cannot rot. The label after the bar is whatever reads naturally
in the sentence: *"…severe viral `[[3|bronchiolitis]]`…"* reads as
"…severe viral bronchiolitis…", with the two words linked.
Where the id comes from: **🔗 Link an article**, in the editor's toolbar. Type
a few words, click the article, and the marker is on your clipboard with the
article's own title as the label — click a *section* instead and you get
`[[264#workup|Workup]]`, which opens the reader at that heading. Drafts are
marked as such in the list, because a link to one is a link to nothing yet.
The id is also in the article's URL — `/articles/264` is id 264 — and on the
editor's ID/Slug/marker buttons, which copy the whole thing ready to paste.
The section part is the section's own id, and it is optional in both
directions: a section renamed after the link was written leaves the reader at
the top of the right article rather than nowhere, which is why a missing
section is not reported as a broken link.
What happens at the far end: the link opens the article **in a side pane** next
to what you are reading, rather than navigating away — following a reference
does not lose your place. A marker pointing at an article that does not exist is
reported on the editor as a broken link rather than rendering as dead text.
Inside a **card or a list row** the same marker is flattened to its label
instead of being rendered — a link inside something that is already a link would
swallow the click.
## Key points — `==…==`
`Give ==IVIG within 10 days== of fever onset.` — the words between the double
equals are highlighted in yellow, the way a highlighter is run over a textbook.
Use it in the **high-yield view**, which is what it is for: a summary where
nothing is emphasised is a shorter article, not a revision aid. A few phrases a
section, never a whole paragraph.
Rules the parser follows, so you can predict it:
- A highlight may not run across a line break, so one stray `==` cannot swallow
the rest of a section.
- `Sodium == 140` is a lab value, not an unclosed highlight: a lone marker stays
the characters you typed.
- `====` is four equals signs, not an empty highlight.
The Key button in the editor toolbar wraps the selection for you.
## Teaching tips — `{{phrase|the tip}}`
`{{stridor|Inspiratory stridor is extrathoracic until proven otherwise}}` — the
phrase is underlined in the prose, and the sentence appears where the phrase is,
on a click. It is a cross-reference minus the article: sometimes what a learner
needs is one sentence, and writing a whole article to hang it on is how a
sentence goes unwritten.
The phrase may not contain a bar or a brace; the tip may not contain braces.
## Maths
`$…$` inline and `$$…$$` for a display block, rendered by KaTeX. Serum
osmolality set as plain text is a different sentence from the one you wrote.
## The three views
Every section belongs to exactly one of them, chosen in the editor's view tabs.
A view with no sections in it is not offered to the reader at all.
| Variant | What it is for |
|---|---|
| **long** | The full article: pathophysiology, presentation, workup, management. The body of the work, and the default for anything written before views existed. |
| **short** | The high-yield revision view. Tight lists of what a candidate must carry into an exam — not a summary of the long article's structure. This is where `==key points==` belong. |
| **clinical** | What to do at the bedside, when the topic has one. Assessment, immediate management, escalation, disposition. Omit it entirely for a topic that is not acted on clinically. |
An AI draft is asked for all three (see `ARTICLE_DRAFT_PROMPT`); it is told
explicitly *not* to categorise the article or link it to questions, because both
of those are judgements an educator makes.
## Linking questions to an article
From the article editor, under **Linked questions**:
- **One at a time** — search by the stem, choose whether the link lands on the
whole article or on one section.
- **A whole topic at once** — choose a category, and every question filed under
it (including its subtopics, unless you say otherwise) is linked in one action.
The button carries the number, so you can see that "Cardiology" means 43
questions before you press it. Up to 300 in one go.
Either way these are ordinary link rows: removable one at a time, and a
*snapshot* rather than a rule. Questions filed under that category tomorrow are
**not** linked automatically — the alternative would silently attach new
questions to an article nobody has looked at since.
The same list is editable from each question's own editor, which is the same
relationship seen from the other end.
## Linking cards to a question, and to an article
Cards go the other way round: the link is made **from the card**, in the deck
browser, and read from the question's end only.
- Open **Cards**, then the deck, then the ⛓ control on a card.
- Search a question by its stem, or an article by its title, and link it.
What a learner then sees: under the correct answer, beside the ▤ chips for
topic reading, a **▦ chip naming the deck** — one chip per deck however many of
its cards are tied to that question, because three doors to the same room is
one door too many. The same chips appear in the answer review of a finished
attempt.
Why only from the card's side: a card that listed the questions it belongs to
would hand a learner revising the deck the shape of the exam, and the back of a
card is an answer.
**A deck nobody shared is invisible.** Cards generated from an article land in
a private deck called *Cards: <title>*, owned by whoever pressed the button;
it appears in nobody else's list, and the chip is not drawn for anyone who
cannot open the deck. Sharing is a deliberate second action, after reading what
the model wrote.
## What can be linked to what
| From | To | Where you do it | What the reader gets |
|---|---|---|---|
| Article prose | Article | `[[264\|label]]`, or 🔗 Link an article | A link with a hover card: excerpt, new tab, or a pane beside what they are reading |
| Article prose | One section | `[[264#workup\|label]]`, or 🔗 → the section | The same card, opening the reader at that heading |
| Article | Question | Editor → Linked questions | Practice under the article, and the article under the question's answer |
| Question | Article | Question editor → the same list | ▤ chips under the correct answer, landing on the article or one of its sections |
| Card | Question | Cards → deck → ⛓ | ▦ chip under the correct answer, opening the deck to study |
| Card | Article | Cards → deck → ⛓ | The card listed under *Related cards* on the article |
| Explanation prose | Article | `[[264\|label]]`, same as anywhere | The same hover card |
Both directions can land on **one section** rather than the whole article: a
question→article link has a section picker beside it, and prose says it with
`#``[[264#workup|the workup]]`.
## Deleting
- A draft that was **never published** is deleted outright. There is nothing to
restore, and a trash full of abandoned stubs is a second list to maintain.
- Anything that **has been published**, even once, goes to the **trash** in
Editorial and can be restored exactly as it was. Somewhere there is a
learner's note against one of its sections, a question linked to it, and a
link somebody sent a colleague.
The confirmation on the editor says which of the two you are about to do.