Skip to main content
Recipe number 214

Cookbook · Chapter 13 · CMS integration

Proofreading marks: strike, replace and insert

An editor's corrections drawn on a laid-out story page in postext-viewer: struck words, replacements written above them and insertion carets.

On this page
Output
Canvas
Postext
Tested with Postext 1.103.1
Needs ≥ 1.103.0
Licence
Updated 4 Dec 2026
Code MIT · Text CC BY 4.0
The first proof with five corrections drawn on the page: struck words, replacements written above the line and an insertion caret, each named in the list beside it.
The first proof with five corrections drawn on the page: struck words, replacements written above the line and an insertion caret, each named in the list beside it.
  • Trim 130 × 200 mm
  • 1 column
  • Libre Caslon Text 10/16
  • 1 page
  • Level
  • Postext 1.103.1
  • Laid out in 60 ms
  • 107 lines of code

In short

The first page of a short story with an editor's corrections on it, as a proofing tool shows them: crossed-out words, new words written above the old ones, and a small caret where a word goes in. A list beside the page names each one.

What you'll build

The opening page of a short story, Platform Two, with the copy editor's first-proof corrections on it. A doubled word and a stray very are struck through in red; lain and recieved are struck with the right words written on small labels just above them; a green caret under the line marks where in is missing. The list on the right holds the same five corrections, each with the words as they stand and what replaces them. Press a mark on the page, or tab to it and press Enter, and its entry is picked.

This recipe answers

  • How do I show proofreading marks (deletions, replacements, insertions) on the laid-out pages?

The short answer

script.js · lines 107–116in full code
const view = createViewer(document.getElementById('viewer'), {
  document: doc, markdown, zoom: 'fit-width', labels: L.viewer,
  annotations: edits, // strike, replace (text over the struck words) and insert (a caret)
});
const entries = new Map(edits.map((e) => [e.id, entry(e)]));
const pick = (id) => {
  for (const [key, li] of entries) li.classList.toggle('active', key === id);
};
view.on('annotationclick', ({ id }) => pick(id)); // pointer, Enter or Space
pick('e2');

The corrections drawn on the page, and a press on one picks its entry

Ingredients

Type
Libre Caslon Text (SIL OFL 1.1)
Assets
None: every picture is drawn in code

Method

#1 · Leave room between the lines

script.js · lines 30–51in full code
const config = {
  locale: t({ en: 'en-gb', es: 'es' }),
  colorPalette,
  page: { sizePreset: 'custom', width: mm(130), height: mm(200), dpi: 150,
    margins: { top: mm(22), bottom: mm(24), left: mm(18), right: mm(18) } },
  layout: { layoutType: 'single' },
  bodyText: { fontFamily: 'Libre Caslon Text', fontSize: pt(10), lineHeight: pt(16),
    color: col('ink'), boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: mm(5), indentAfterHeading: false,
    hyphenation: { enabled: true }, optimalLineBreaking: true,
    avoidWidows: true, avoidOrphans: true, avoidRunts: true },
  headings: { fontFamily: 'Libre Caslon Text', color: col('accent'), fontWeight: 400, levels: [
    { level: 1, fontSize: pt(22), lineHeight: pt(28), italic: true,
      marginTop: pt(16), marginBottom: pt(24) },
  ] },
  header: { elements: [] },
  footer: { elements: [
    { kind: 'text', id: 'folio', content: '{pageNumber}', fontFamily: 'Libre Caslon Text',
      fontSize: pt(9), color: col('accent'), align: 'center',
      placement: { anchor: { to: 'page', edge: 'bottom-center' }, offset: { y: mm(-12) } } },
  ] },
};

Replacement and insertion labels are set at 0.62 of the text's em and stand just over the line they correct, in the leading. A 10 pt face on 16 pt leaves them room, so a label covers little of the line above; on tight leading the labels sit on paper-coloured backdrops that keep both readable.

#2 · Store each correction as a range

script.js · lines 81–95in full code
// [kind, a quote that finds the place, the words marked in it, the new text]
// A tool stores the offsets; the pen finds them from quotes so that both editions run.
const edits = t({
  en: [['strike', 'for for forty', 'for '], ['replace', 'had lain her', 'lain', 'laid'],
    ['strike', 'the very last', 'very '], ['replace', 'had recieved a', 'recieved', 'received'],
    ['insert', 'nothing the dark', 'the dark', 'in ']],
  es: [['replace', 'habían dos faroles', 'habían', 'había'],
    ['replace', 'había recivido', 'recivido', 'recibido'], ['insert', 'segura que', 'que', 'de '],
    ['strike', 'todo el el valle', 'el '], ['strike', 'subió arriba', ' arriba']],
}).map(([kind, quote, words, text], i) => {
  const start = markdown.indexOf(quote) + quote.indexOf(words);
  // An insertion marks a point: the range is empty, before the words that follow it.
  const end = kind === 'insert' ? start : start + words.length;
  return { id: `e${i + 1}`, kind, range: { start, end }, text };
});

A deletion and a replacement mark the words they change; a replacement also carries its new text. An insertion marks a point, so its range is empty (start === end) and the caret goes under the line at that offset. These are the same records applyEdits takes when the corrections are accepted.

#3 · Draw them and listen for presses

The code is the short answer above. The viewer lays the marks out in each line's own frame, so a strike crosses the middle of the letters and a replacement stands over its words, also on right-to-left and vertical pages. annotationclick fires for a pointer press and for Enter or Space on a mark, since each mark is a button named "Replacement: laid" for the keyboard.

The whole recipe

// ═══ Postext Cookbook · Nº 214 · Proofreading marks: strike, replace and insert ══════
// https://postext.dev/en/cookbook/proofreading-marks-on-pages
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: Libre Caslon Text (SIL OFL 1.1) · Needs postext ≥ 1.103.0
//
// The first page of a short story with an editor's corrections drawn on it, as a proofing
// tool shows them: struck words, a replacement written over the words it replaces, and a
// caret where a word goes in. The list beside the page is the same corrections; pressing a
// mark, with the pointer or the keyboard, picks its entry.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { createViewer } from 'https://esm.sh/postext-viewer';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'proofreading-marks-on-pages';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: semantic colours, every one linked by id
const palette = {
  ink: '#1d1b19', // text
  accent: '#5b4a8a', // a dusk violet: the story's title and the folios
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
  ...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
  { id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion

// #region page: a short-story page with generous leading, room for the marks between lines
const config = {
  locale: t({ en: 'en-gb', es: 'es' }),
  colorPalette,
  page: { sizePreset: 'custom', width: mm(130), height: mm(200), dpi: 150,
    margins: { top: mm(22), bottom: mm(24), left: mm(18), right: mm(18) } },
  layout: { layoutType: 'single' },
  bodyText: { fontFamily: 'Libre Caslon Text', fontSize: pt(10), lineHeight: pt(16),
    color: col('ink'), boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: mm(5), indentAfterHeading: false,
    hyphenation: { enabled: true }, optimalLineBreaking: true,
    avoidWidows: true, avoidOrphans: true, avoidRunts: true },
  headings: { fontFamily: 'Libre Caslon Text', color: col('accent'), fontWeight: 400, levels: [
    { level: 1, fontSize: pt(22), lineHeight: pt(28), italic: true,
      marginTop: pt(16), marginBottom: pt(24) },
  ] },
  header: { elements: [] },
  footer: { elements: [
    { kind: 'text', id: 'folio', content: '{pageNumber}', fontFamily: 'Libre Caslon Text',
      fontSize: pt(9), color: col('accent'), align: 'center',

The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)

Variations

#Accept every correction

Import applyEdits from https://esm.sh/postext/annotate, write the corrections into the Markdown and show the new layout.

 view.on('annotationclick', ({ id }) => pick(id)); // pointer, Enter or Space
+const { markdown: fixed } = applyEdits(markdown, edits.map((e) => ({ ...e.range, text: e.text ?? '' })));
+view.setDocument(await buildDocumentWithFonts({ markdown: fixed }, config, kitFonts(FONTS)), fixed);
+view.setAnnotations([]);

#Set the labels in the book's face

The marks set their own text in system-ui unless told otherwise.

   document: doc, markdown, zoom: 'fit-width', labels: L.viewer,
+  marks: { fontFamily: 'Libre Caslon Text' },

Credits

Text
Original prose, CC BY 4.0
Fonts
Libre Caslon Text (SIL OFL 1.1)