---
title: "Recipe: a long document or article"
description: "A document longer than a screen (an article, a help page, a Markdown note, a transcript) is one text per block: a paragraph, a heading, a whole list, a whole code block, a quote."
modificationDate: "2026-11-13"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: a long document or article

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/long-text: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

A document longer than a screen (an article, a help page, a Markdown note, a
transcript) is one `text` per block: a paragraph, a heading, a whole list, a
whole code block, a quote. The blocks sit in a `column` in the `scroll`, keyed:

```prompt Show a long article or document
Make the Exact app in this folder show a document longer than a screen (an article, a help page, a Markdown note, a transcript) as one text per block. Use https://github.com/expo/exact/blob/main/docs/recipes/long-text.md as the source for each step. The Exact checkout has the same page at docs/recipes/long-text.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say which document, whether it is Markdown or plain text, and whether app.ts or a server holds it, ask me before you write code.
3. Split the document into blocks in app.ts or on the server, at the boundaries the source marks, and return each block with an `id`. Never put the whole document in one `text`: past a length Apple does not document, iOS and macOS set a text without kerning, ligatures or Arabic joining.
4. For Markdown, a block is what a Markdown parser calls one. A fenced code block or a list can hold blank lines and is one block: do not split at every blank line. For plain text, a block is a paragraph: split at blank lines, or at single line breaks where the text has no blank lines. A line break can be `\n`, `\r\n` or U+2029.
5. Never split inside a paragraph, however long it is. Footnotes are numbered within one text: write the numbers into the source before you split, or keep a document with footnotes in one text.
6. In app.contract, read the blocks as a resource and draw a `scroll` that holds a `column` with a `gap`. In the column, write a `for` over the blocks with `key` set to the block's id, and one `text` for each block. A Markdown block takes `markup="markdown"`.
7. Give each block a `testId` from its id. Add a test in app.test.contract with a document that has a code block or a list with a blank line in it: after `clock data`, expect the last block (`expect tree has`) and no block after it (`expect tree missing`).
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me which document the app shows, where it is split and how many blocks it has, what the tests and checks reported, and the launch command for each target platform.
```

```contract
shape Block
  id: number
  text: string
shape Article
  blocks: Block[]

component Reader
  resource article = loadArticle() as shape Article
  view
    scroll height="100%"
      column padding=16 gap=12
        for block in article.blocks key=block.id
          text block.text markup="markdown"
```

Make the blocks in `app.ts` or on the server, at the boundaries the source
already marks:

- **Markdown:** a block is what a Markdown parser calls one. A fenced code block
  or a list can hold blank lines and is still one block, so a split at every
  blank line is wrong.
- **Plain text:** a block is a paragraph, as the text separates them: by blank
  lines, or by single line breaks where it has no blank lines. A stanza's or an
  address's lines stay together in one text. Line breaks can be `\n`, `\r\n` or
  U+2029.
- **Never inside a paragraph.** A paragraph longer than Apple's limit (below)
  stays one text: set without shaping is better than broken.
- **Footnotes** are numbered within one text, so split blocks each count from
  [1]. Write the numbers into the source before splitting, or keep a document
  with footnotes in one text.

```ts
import type { Answer, Sources } from './app.contract.d.ts';
export const grants = '';
const blocks = [
  '# Folding phones',
  'A paragraph is one text, however long it is.',
  '- A list is one block\n- with all of its items',
  '```\nlet code = "one block, blank lines and all"\n\nlet more = code\n```',
];
const sources: Sources = {
  loadArticle: () => ({ blocks: blocks.map((text, id) => ({ id, text })) }),
};
export const answer: Answer = (source, args, store, storage, native) => sources[source](args, store, storage, native);
```

Why not one text for the whole document:

- **Apple's text layout declines a long string.** Core Text's `CTTypesetter.h`
  calls proper layout of some text "unreasonable effort" and makes it opt-in
  (`kCTTypesetterOptionAllowUnboundedLayout`). Past a length it does not
  document, iOS and macOS set a text without kerning, ligatures or Arabic
  joining, and run its right-to-left text left to right. The length was 10,240
  UTF-16 units on iOS 27.1 and macOS 27.2; it can change, and this rule does
  not depend on it.
- **Layout starts again at each paragraph:** bidi
  ([UAX #9](https://www.unicode.org/reports/tr9/), P1) and line breaking
  ([UAX #14](https://www.unicode.org/reports/tr14/)) do, so a paragraph alone
  lays out as it does in a longer text. A split inside one loses kerning,
  ligatures and joining across it, and its lines cannot wrap across it.
- **Work follows the blocks:** each text is measured, cached and painted on
  its own, and texts out of view are not painted.

One Markdown text leaves a blank line between its blocks; here the column's
`gap` is that space.
