Με λίγα λόγια
Η πρώτη σελίδα ενός διηγήματος με τις διορθώσεις του επιμελητή, όπως τις δείχνει ένα εργαλείο δοκιμίων: διαγραμμένες λέξεις, νέες λέξεις γραμμένες πάνω από τις παλιές και ένα μικρό σημάδι όπου λείπει λέξη. Μια λίστα δίπλα τις ονομάζει.
Τι θα στοιχειοθετήσετε
Η πρώτη σελίδα ενός διηγήματος, του Platform Two, με τις διορθώσεις της πρώτης δοκιμής από τον επιμελητή κειμένου. Μια διπλή λέξη και ένα περιττό very είναι διαγραμμένα με κόκκινο· τα lain και recieved είναι διαγραμμένα με τη σωστή λέξη γραμμένη σε μικρή ετικέτα ακριβώς από πάνω· ένα πράσινο σημάδι κάτω από τη γραμμή δείχνει πού λείπει το in. Η λίστα στα δεξιά κρατά τις ίδιες πέντε διορθώσεις, την καθεμιά με τις λέξεις όπως είναι και ό,τι τις αντικαθιστά. Πατήστε ένα σημάδι στη σελίδα, ή φτάστε σε αυτό με το Tab και πατήστε Enter, και επιλέγεται η εγγραφή του.
Αυτή η συνταγή απαντά
- Πώς δείχνω διορθωτικά σημεία (διαγραφές, αντικαταστάσεις, προσθήκες) στις σελιδοποιημένες σελίδες;
Η σύντομη απάντηση
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');
Υλικά
- Λειτουργίες
- Σημάδια σχολιασμούΠρόγραμμα προβολής σελίδων (postext-viewer)Γραμματοσειρές πριν από τη σελιδοποίηση
- Γραμματοσειρές
- Libre Caslon Text (SIL OFL 1.1)
- Αρχεία
- Κανένα: κάθε εικόνα σχεδιάζεται με κώδικα
Προετοιμασία
#1 · Αφήστε αέρα ανάμεσα στις γραμμές
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) } } },
] },
};
Οι ετικέτες αντικατάστασης και προσθήκης στοιχειοθετούνται στο 0,62 του σώματος του κειμένου και κάθονται ακριβώς πάνω από τη γραμμή που διορθώνουν, στο διάστιχο. Σώμα 10 σε διάστιχο 16 τους αφήνει χώρο, οπότε η ετικέτα σκεπάζει λίγο από την από πάνω γραμμή· με στενό διάστιχο, οι ετικέτες έχουν φόντο στο χρώμα του χαρτιού που κρατά και τις δύο ευανάγνωστες.
#2 · Αποθηκεύστε κάθε διόρθωση ως εύρος
// [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 };
});
Η διαγραφή και η αντικατάσταση σημαδεύουν τις λέξεις που αλλάζουν· η αντικατάσταση φέρει και το νέο της text. Η προσθήκη σημαδεύει ένα σημείο, άρα το εύρος της είναι κενό (start === end) και το σημάδι μπαίνει κάτω από τη γραμμή σε εκείνη τη θέση. Είναι οι ίδιες εγγραφές που παίρνει η applyEdits όταν οι διορθώσεις γίνονται δεκτές.
#3 · Σχεδιάστε τες και ακούστε τα πατήματα
Ο κώδικας είναι η σύντομη απάντηση παραπάνω. Η προβολή διατάσσει τα σημάδια στο πλαίσιο κάθε γραμμής, οπότε η διαγραφή περνά από τη μέση των γραμμάτων και η αντικατάσταση στέκεται πάνω από τις λέξεις της, και σε σελίδες από δεξιά προς τα αριστερά ή κάθετες. Το annotationclick εκπέμπεται με πάτημα του δείκτη και με Enter ή Space πάνω σε σημάδι, γιατί κάθε σημάδι είναι κουμπί για το πληκτρολόγιο με όνομα «Replacement: laid».
Η πλήρης συνταγή
// ═══ 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',
<main id="pages">
<div id="viewer"></div>
<aside id="panel">
<h2 id="heading"></h2>
<ol id="edits"></ol>
</aside>
</main>
/* The host's frame: the viewer on the left, the list of corrections on the right.
The viewer fills its container, so the container gets a height. */
main#pages {
display: grid; grid-template-columns: minmax(0, 1fr) 320px; height: max(560px, 100vh);
justify-items: stretch; gap: 0; padding: 0;
}
#viewer { min-height: 0; }
#viewer .postext-viewer { --pv-background: #e7e4ec; --pv-focus: #5b4a8a; }
#panel {
overflow: auto; padding: 20px 18px; background: #fbfafc; border-left: 1px solid #d3cfdb;
font: 15px/1.4 system-ui, sans-serif; color: #1d1b19;
}
#panel h2 { margin: 0 0 12px; font-size: 18px; }
#edits { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#edits button {
display: block; width: 100%; min-height: 44px; padding: 9px 12px; text-align: left;
background: #fff; border: 1px solid #dcd8e3; border-radius: 6px;
font: inherit; color: inherit; cursor: pointer;
}
#edits button:focus-visible { outline: 2px solid #5b4a8a; outline-offset: 2px; }
#edits li.active button { border-color: #5b4a8a; box-shadow: inset 4px 0 0 #5b4a8a; }
#edits b {
display: block; font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
color: #5e5a66;
}
#edits del { color: #b3261e; }
#edits ins { color: #17733f; text-decoration: none; font-weight: 600; }
#edits del:empty, #edits ins:empty { display: none; }
Το συντεθειμένο script.js εκτελείται ως έχει: επικολλήστε το στο module script οποιασδήποτε σελίδας ή ανοίξτε τη συνταγή στο CodePen. Φάκελος της συνταγής στο GitHub ↗ (ανοίγει σε νέα καρτέλα)
Παραλλαγές
#Αποδεχτείτε όλες τις διορθώσεις
Εισαγάγετε την applyEdits από το https://esm.sh/postext/annotate, γράψτε τις διορθώσεις στο Markdown και δείξτε τη νέα σελιδοποίηση.
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([]);#Στοιχειοθετήστε τις ετικέτες με τη γραμματοσειρά του βιβλίου
Τα σημάδια στοιχειοθετούν το δικό τους κείμενο σε system-ui, αν δεν τους πει κανείς κάτι άλλο.
document: doc, markdown, zoom: 'fit-width', labels: L.viewer,
+ marks: { fontFamily: 'Libre Caslon Text' },Ευχαριστίες
- Συνταγή
- Ignacio Ferro
- Κείμενο
- Πρωτότυπο κείμενο, CC BY 4.0
- Γραμματοσειρές
- Libre Caslon Text (SIL OFL 1.1)
- Κώδικας
- MIT, όπως το Postext
Επεξεργασία αυτού του κειμένου ↗ (ανοίγει σε νέα καρτέλα)Φάκελος της συνταγής στο GitHub ↗ (ανοίγει σε νέα καρτέλα)



