# Παραπομπές και στατιστικά μακριά από τις άκρες των γραμμών

> Δίστηλο κλινικό άρθρο στοιχειοθετημένο δύο φορές: το πρώτο δοκίμιο αναφέρει κάθε παραπομπή ή σύμβολο σε άκρη γραμμής, το δεύτερο κοστολογεί αυτές τις αλλαγές.

- Έκδοση HTML: https://postext.dev/el/cookbook/clinical-paper-line-edges
- Συνταγή Αρ. 186 · Τυπογραφία και κείμενο · Επίπεδο 2 (Μεσαίο) · Έξοδοι: Canvas
- Είδη: Επιστημονικά άρθρα και ακαδημαϊκά κείμενα
- Απαιτεί postext ≥ 1.79.0 · δοκιμασμένη με 1.79.0 στις 2026-11-12
- Σελίδες: [211](https://postext.dev/cookbook/clinical-paper-line-edges/en/p01.webp?v=56d4126e), [212](https://postext.dev/cookbook/clinical-paper-line-edges/en/p02.webp?v=56d4126e), [213](https://postext.dev/cookbook/clinical-paper-line-edges/en/p03.webp?v=56d4126e), [213](https://postext.dev/cookbook/clinical-paper-line-edges/en/p06.webp?v=56d4126e)
- Άνοιγμα στο Sandbox: https://postext.dev/el/sandbox#recipe=clinical-paper-line-edges&lang=en (.postext: https://postext.dev/cookbook/clinical-paper-line-edges/en/clinical-paper-line-edges.postext)
- Τελευταία ενημέρωση: 2026-11-12
- Άλλες γλώσσες: [en](https://postext.dev/en/cookbook/clinical-paper-line-edges.md), [es](https://postext.dev/es/cookbook/clinical-paper-line-edges.md), [ca](https://postext.dev/ca/cookbook/clinical-paper-line-edges.md), [de](https://postext.dev/de/cookbook/clinical-paper-line-edges.md), [fr](https://postext.dev/fr/cookbook/clinical-paper-line-edges.md), [it](https://postext.dev/it/cookbook/clinical-paper-line-edges.md), [pt](https://postext.dev/pt/cookbook/clinical-paper-line-edges.md), [zh](https://postext.dev/zh/cookbook/clinical-paper-line-edges.md), [ja](https://postext.dev/ja/cookbook/clinical-paper-line-edges.md), [ar](https://postext.dev/ar/cookbook/clinical-paper-line-edges.md)

## Με λίγα λόγια

Σε στενή στήλη με πλήρη στοίχιση, μια παραπομπή όπως το [2, 3] μπορεί να ξεκινήσει μόνη της γραμμή, και το p < 0.05 να σπάσει μετά το σύμβολο. Το άρθρο στοιχειοθετείται δύο φορές: μία που δείχνει πού γίνεται, μία που σχεδόν το αποφεύγει.

## Τι θα στοιχειοθετήσετε

Τρεις σελίδες ενός παιδιατρικού περιοδικού, 170 × 240 mm, στοιχειοθετημένες σε δύο στήλες 66 mm με πλήρη στοίχιση σε STIX Two Text: μια πρωτότυπη μελέτη υπερηχογραφήματος πνεύμονα για την πνευμονία με αριθμημένο κατάλογο βιβλιογραφίας Vancouver. Μια τόσο στενή στήλη αφήνει λίγες επιλογές στο σπάσιμο των γραμμών, και σε τρία σημεία το αγγλικό κείμενο σπάει άσχημα. Μια παραπομπή, *[2, 3]*, ξεκινά μόνη της μια γραμμή, μακριά από τη λέξη που στηρίζει, και δύο φορές ο λόγος πιθανοφάνειας *LR− = 0.09* σπάει μετά το σύμβολο του ίσον. Το πρώτο δοκίμιο στοιχειοθετείται με `citationBreaks` και `operatorBreaks` σε `'warn'`. Δεν αλλάζει καμία αλλαγή γραμμής, σημαδεύει την καθεμία με μια απαλή κεχριμπαρένια ταινία και τις απαριθμεί σε ένα σημείωμα μετά τη βιβλιογραφία. Το δεύτερο δοκίμιο στοιχειοθετείται με `'avoid'`, και από τις τρεις μένει μία. Η ισπανική έκδοση στοιχειοθετεί την ίδια μελέτη με υποδιαστολή.

**Αυτή η συνταγή απαντά:**

- Πώς εμποδίζω έναν αριθμό παραπομπής ή ένα στατιστικό όπως το p < 0.05 να σπάσει στο τέλος μιας γραμμής;
- Πώς στοιχειοθετώ τους αριθμούς των βιβλιογραφικών παραπομπών ως εκθέτες και κάνω τα DOI ενεργούς συνδέσμους, όπως τα ιατρικά περιοδικά;

## Η σύντομη απάντηση

```js
// script.js, γραμμές 27–42
const bodyText = {
  fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  referenceBold: false, textAlign: 'justify', firstLineIndent: mm(3.5),
  indentAfterHeading: false, hyphenation: { enabled: true },
  optimalLineBreaking: true, // the rules price breaks in the Knuth–Plass breaker
  avoidWidows: true, avoidOrphans: true, avoidRunts: true,
  // A line that opens on a citation, "[8, 9]" (citationBreak), or ends or opens on a sign
  // set between spaces, "p <" / "0.05" (operatorBreak). 'warn' reports each one and changes
  // nothing; 'avoid' adds the penalty to the demerits of those breaks and reports the ones
  // it keeps. The first proof sets 'warn' (see proofs).
  citationBreaks: 'avoid', operatorBreaks: 'avoid',
  // 10000 by default, what a line spaced to the limit costs. A 66 mm column offers few other
  // breaks; at 30000 the breaker takes looser lines, never past maxWordSpacing.
  citationBreakPenalty: 30000, operatorBreakPenalty: 30000,
};
```

## Υλικά

**Διδάσκει**

- [Παραπομπές και σύμβολα στις άκρες των γραμμών](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο): Εντοπίζει γραμμές που αρχίζουν με αριθμημένη παραπομπή ([12], (12–15)) ή τελειώνουν ή αρχίζουν με σύμβολο ανάμεσα σε διαστήματα (p < 0.05, LR+ = 19.19) και τις αναφέρει (bodyText.citationBreaks / operatorBreaks: 'warn') ή κάνει τον αλγόριθμο αλλαγής γραμμής να στοιχειοθετήσει την παράγραφο αλλιώς ('avoid', με κόστος citationBreakPenalty / operatorBreakPenalty).
- [Βέλτιστη αλλαγή γραμμής (Knuth–Plass)](https://postext.dev/el/docs/justification.md#knuth-plass-η-ματιά-σε-ολόκληρη-την-παράγραφο): Σπάει κάθε παράγραφο ως σύνολο ώστε τα διαστήματα ανάμεσα στις λέξεις να είναι ομοιόμορφα, μέσα σε όρια διαστημάτων, αντί να γεμίζει τις γραμμές μία μία.

**Χρησιμοποιεί επίσης**

- [Βιβλιογραφικές παραπομπές σε στιλ παραπομπών](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία)
- [Βιβλιογραφία από τις αναφορές](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία)
- [Επισημάνσεις](https://postext.dev/el/docs/document-format-inline.md#επισημάνσεις)
- [Συλλαβισμός και γλώσσα του εγγράφου](https://postext.dev/el/docs/justification.md#υποστηριζόμενες-γλώσσες)
- [Μία ή δύο στήλες](https://postext.dev/el/docs/configuration-page-layout.md#τύποι-διάταξης)
- [Σχεδιασμένες εναρκτήριες σελίδες](https://postext.dev/el/docs/configuration-headings.md#πλάτος-και-προηγμένη-σχεδίαση)
- [Ιδιότητες επικεφαλίδων](https://postext.dev/el/docs/document-format.md#χαρακτηριστικά-επικεφαλίδων)
- [Στιλ επικεφαλίδων](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)
- [Τρέχουσες κεφαλίδες και αριθμοί σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα)
- [Κεφαλίδες ανά ρόλο σελίδας](https://postext.dev/el/docs/configuration-headers-footers.md#στοιχεία-κειμένου)
- [Συμμετρικά περιθώρια](https://postext.dev/el/docs/configuration-page-layout.md#κατοπτρικά-περιθώρια)
- [Πλαίσια σημειώσεων](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων)
- [Σημασιολογική χρωματική παλέτα](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων)
- [Σκόπιμη έξοδος από το πλέγμα](https://postext.dev/el/docs/architecture.md#στοιχεία-που-σπάνε-το-πλέγμα)
- [Στιλ παραγράφων](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)
- [Προκαταρκτικά με λατινική αρίθμηση](https://postext.dev/el/docs/document-format-directives.md#numbering)
- [Εκθέτες και δείκτες](https://postext.dev/el/docs/document-format-inline.md#μορφοποίηση-μέσα-στη-γραμμή)
- [Κεφάλαια χωρίς αρίθμηση](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων)

**Η διαμόρφωση με μια ματιά**

- [`bodyText`](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο), [`calloutStyles`](https://postext.dev/el/docs/configuration-callouts.md#στιλ-πλαισίων), [`checks`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#έλεγχος-περιεχομένου-διαμόρφωση), [`citations`](https://postext.dev/el/docs/configuration-notes-references.md#βιβλιογραφικές-παραπομπές), [`colorPalette`](https://postext.dev/el/docs/configuration-fonts-colors-viewers.md#παλέτα-χρωμάτων), [`footer`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`header`](https://postext.dev/el/docs/configuration-headers-footers.md#κεφαλίδες-και-υποσέλιδα), [`headingStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-επικεφαλίδων), [`headings`](https://postext.dev/el/docs/configuration-headings.md#επικεφαλίδες), [`layout`](https://postext.dev/el/docs/configuration-page-layout.md#διάταξη), [`locale`](https://postext.dev/el/docs/configuration-language.md#συλλαβισμός), [`markStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-επισήμανσης), [`page`](https://postext.dev/el/docs/configuration-page-layout.md#σελίδα), [`paragraphStyles`](https://postext.dev/el/docs/configuration-styles.md#στιλ-παραγράφων)

**API**

- [`LOCALES`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`STYLES`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`buildDocumentWithFonts`](https://postext.dev/el/docs/configuration-programmatic-usage.md#φόρτωση-γραμματοσειρών-πριν-από-τη-σελιδοποίηση), [`createCiteprocEngine`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`registerCitationEngine`](https://postext.dev/el/docs/document-format-notes-references.md#βιβλιογραφικές-παραπομπές-και-βιβλιογραφία), [`renderPageToCanvas`](https://postext.dev/el/docs/configuration-programmatic-usage.md#απόδοση-σελίδας-σε-bitmap)

**Γραμματοσειρές**

- STIX Two Text (OFL-1.1), IBM Plex Sans (OFL-1.1), IBM Plex Sans Condensed (OFL-1.1)

## Προετοιμασία

### 1 · Μια τιμή για δύο είδη αλλαγής γραμμής

Ο κώδικας είναι η [σύντομη απάντηση](https://postext.dev/el/cookbook/clinical-paper-line-edges.md#η-σύντομη-απάντηση) παραπάνω. Μια αλλαγή γραμμής σε παραπομπή είναι μια γραμμή που αρχίζει με μια αριθμημένη παραπομπή ή με το δεύτερο μισό της, όπως το *5]* μετά το *[4,*. Μια αλλαγή γραμμής σε τελεστή είναι μια γραμμή που τελειώνει ή αρχίζει με ένα σύμβολο ανάμεσα σε διαστήματα: `=`, `<`, `±`, `×`, το μείον. Το `'warn'` αναφέρει και τα δύο και αφήνει τις γραμμές όπως είναι. Το `'avoid'` προσθέτει μια ποινή στις ποινές αυτών των αλλαγών γραμμής, και ο αλγόριθμος Knuth–Plass ψάχνει άλλον τρόπο να στοιχειοθετήσει την παράγραφο. Χρειάζεται το `optimalLineBreaking`, αφού ο άπληστος αλγόριθμος δεν έχει ποινές στις οποίες να προσθέσει.

Η προεπιλεγμένη ποινή, 10000, είναι το κόστος μιας γραμμής τεντωμένης ως το όριο του διαστήματος λέξεων, οπότε ο αλγόριθμος δεν ανοίγει ποτέ μια γραμμή πέρα από αυτό το όριο για να κρατήσει μια παραπομπή με τη λέξη της. Σε αυτή τη στήλη τα 10000 άφησαν δύο αλλαγές γραμμής σε κάθε έκδοση. Στα 30000 ο αλγόριθμος δέχεται πιο αραιές γραμμές, πάντα μέσα στο `maxWordSpacing`, και μένει μία σε κάθε έκδοση. Μια υψηλότερη τιμή δεν άλλαξε τίποτε άλλο: η τελευταία αλλαγή γραμμής δεν έχει εναλλακτική μέσα στο όριο.

### 2 · Σημαδέψτε τις αλλαγές γραμμής στο κείμενο

```js
// script.js, γραμμές 254–279
// The word before the citation and the citation, or the sign and the number on its other
// side, wrapped in :mark[…]: a band under ordinary text, so the breaks stay where they were.
const wordEnd = (s, i) => i + s.slice(i).search(/[\s;)]|[,.](?!\d)|$/); // 0.09, not 0
function sides(source, w, a, b) { // a warning names line a, before the break, by its source
  if (w.kind === 'citationBreak') { // "colleagues [@simel1991]"
    const cite = source.lastIndexOf('[@', b.sourceStart + 2);
    return [source.lastIndexOf(' ', cite - 2) + 1, source.indexOf(']', cite) + 1];
  }
  if (w.edge === 'end') { // "LR− = 0.09": the sign ends line a, the number opens line b
    const from = source.lastIndexOf(` ${w.text} `, a.sourceEnd) + 1;
    return [from, wordEnd(source, from + w.text.length + 1)];
  }
  const sign = source.indexOf(` ${w.text} `, b.sourceStart - 1); // the sign opens line b
  return [source.lastIndexOf(' ', sign - 1) + 1, sign + 1 + w.text.length];
}
function markBreaks(source, doc, found) {
  const pairs = doc.blocks.flatMap((b) => b.lines.map((line, i) => [line, b.lines[i + 1]]));
  const spans = new Map();
  for (const w of found) {
    const [a, b] = pairs.find(([line]) => line.sourceStart === w.sourceStart) ?? [];
    const [from, to] = b ? sides(source, w, a, b) : [];
    if (from > a?.sourceStart && to > from && to <= b.sourceEnd) spans.set(from, to);
  }
  return [...spans].sort(([x], [y]) => y - x).reduce((md, [from, to]) => `${md.slice(0, from)}`
    + `:mark[${md.slice(from, to)}]{style="edge"}${md.slice(to)}`, source);
}
```

Κάθε προειδοποίηση φέρει το είδος της, την παραπομπή ή το σύμβολο, το κείμενο των δύο γραμμών, τη θέση της πρώτης στην πηγή και τη σελίδα. Το σενάριο βρίσκει αυτές τις δύο γραμμές στο έγγραφο που δημιουργήθηκε και τυλίγει την αλλαγή γραμμής σε `:mark[…]`: τη λέξη πριν από μια παραπομπή και την παραπομπή, ή το σύμβολο και τον αριθμό στην άλλη του πλευρά. Ένα σημάδι ζωγραφίζει μια ταινία κάτω από το κείμενο και αφήνει τις αλλαγές γραμμής εκεί όπου ήταν. Η ταινία δεν φτάνει στον αριθμό που παράγει το στιλ παραπομπών, οπότε στη σελίδα σημαδεύεται μόνο η λέξη πριν από αυτόν.

![Opening page 211: Point-of-care lung ultrasound for community- acquired pneumonia in children: a prospective diagnostic accuracy study.](https://postext.dev/cookbook/clinical-paper-line-edges/en/p01.webp?v=56d4126e)

*Πρώτο δοκίμιο, σελίδα 211: το «LR− = 0.09» σπασμένο στην περίληψη, και το «first» σε άκρη γραμμής με το «[2, 3]» να ανοίγει την επόμενη γραμμή.*

### 3 · Δύο δοκίμια και ένα σημείωμα ερωτημάτων

```js
// script.js, γραμμές 283–303
const KIND = { citationBreak: t({ en: 'citation', es: 'cita' }),
  operatorBreak: t({ en: 'sign', es: 'signo' }) };
const edge = (s, end) => (end ? s.trim().split(/\s+/).slice(-2) : s.trim().split(/\s+/)
  .slice(0, 2)).join('\u00a0').replace(/[.,;]$/, ''); // no-break spaces: no breaks of its own
const query = (doc, w) => `${t({ en: 'p.', es: 'pág.' })}\u00a0${doc.pages[w.pageIndex]
  .pageLabel}, ${KIND[w.kind]}: …${edge(w.lines[0], true)}\u00a0/ ${edge(w.lines[1])}…`;
const slip = (mode, doc, found) => ['', `:::callout{type="slip" title="${mode === 'warn'
  ? t({ en: 'First proof: queries', es: 'Primeras pruebas: consultas' })
  : t({ en: 'Second proof: queries', es: 'Segundas pruebas: consultas' })}"}`,
`citationBreaks / operatorBreaks: '${mode}' · ${found.length} ${found.length === 1
  ? t({ en: 'break', es: 'corte' }) : t({ en: 'breaks', es: 'cortes' })}.`,
...found.flatMap((w) => ['', query(doc, w)]), ':::', ''].join('\n');
const build = (md, mode) => buildDocumentWithFonts({ markdown: md }, { ...config,
  bodyText: { ...bodyText, citationBreaks: mode, operatorBreaks: mode } }, kitFonts(FONTS));
async function proof(mode) {
  const plain = await build(markdown, mode); // pass 1: where the breaks are
  const found = (plain.contentWarnings ?? []).filter((w) => /^(citation|operator)Break$/
    .test(w.kind));
  return build(markBreaks(markdown, plain, found) + slip(mode, plain, found), mode); // pass 2
}
const docs = { warn: await proof('warn'), avoid: await proof('avoid') };
```

Κάθε δοκίμιο δημιουργείται δύο φορές. Η πρώτη δημιουργία βρίσκει τις αλλαγές γραμμής· η δεύτερη στοιχειοθετεί το άρθρο με τα σημάδια και ένα σημείωμα μετά τη βιβλιογραφία, ώστε το σημείωμα να πέφτει στην τελευταία σελίδα. Με τον ίδιο τρόπο επιστρέφει ένας στοιχειοθέτης τα δοκίμια με ερωτήματα. Οι γραμμές του σημειώματος ενώνουν τις λέξεις τους με αδιάσπαστα διαστήματα, ώστε να μην προσθέτουν δικές τους αλλαγές γραμμής. Το `capture.doc` δημοσιεύει τις δύο σημαδεμένες δημιουργίες, `[1, 3]`.

![Page 213: Article information.](https://postext.dev/cookbook/clinical-paper-line-edges/en/p06.webp?v=56d4126e)

*Δεύτερο δοκίμιο, σελίδα 213: το σημείωμα απαριθμεί μία αλλαγή γραμμής που μένει στο άρθρο.*

Η αλλαγή γραμμής που μένει στα αγγλικά είναι το *first* πάνω από το *[2, 3]* στη σελίδα 211. Στα ισπανικά το πρώτο δοκίμιο βρίσκει τέσσερις, ανάμεσά τους το *CP+* πάνω από το *= 19,19* και το *[4,* πάνω από το *5]*, όπου σπάει η ίδια η παραπομπή, και το δεύτερο δοκίμιο κρατά μία, το *anteriores [4,* πάνω από το *5]*.

### 4 · Αριθμημένες παραπομπές σε αγκύλες

```js
// script.js, γραμμές 46–50
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = { style: 'elsevier-vancouver', locale: t({ en: 'en-GB', es: 'es-ES' }),
  marker: 'brackets', collapseRanges: true, // [8, 9] and [4–6], set after a word space
  bibliography: { fontSize: em(0.8), lineHeight: pt(9.6), entrySpacing: pt(1),
    labelWidth: mm(6), labelAlign: 'right', doi: 'hide' } };
```

Ο επεξεργαστής παραπομπών στοιχειοθετεί κάθε `[@key]` ως αριθμό σε αγκύλες μετά από διάστημα λέξεων και συμπτύσσει σειρές όπως το *[4–6]*. Το διάστημα πριν από την αγκύλη και το διάστημα μετά από ένα κόμμα μέσα σε αυτήν είναι και τα δύο σημεία όπου μπορεί να σπάσει μια γραμμή, και γι’ αυτό μια στενή στήλη με πολλές παραπομπές χρειάζεται τον κανόνα.

### 5 · Η ζώνη τίτλου του περιοδικού και το μπλοκ του άρθρου

```js
// script.js, γραμμές 54–78
const text = (id, content, family, size, extra) => ({ kind: 'text', id, content, align: 'left',
  fontFamily: family, fontSize: pt(size), color: col('ink'), overflow: 'wrap', ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
  ...(width && { size: { width: mm(width), height: 'auto' } }) });
const caps = { fontFamily: COND, fontWeight: 600, letterSpacing: pt(1.2),
  textTransform: 'uppercase' };
const JOURNAL = t({ en: 'Ribera Paediatric Journal', es: 'Revista Pediátrica de la Ribera' });
const white = { ...caps, color: col('paper') };
const titleBlock = { enabled: true, minHeight: mm(58), slot: { elements: [
  { kind: 'box', id: 'band', style: { backgroundColor: col('accent') }, placement: {
    anchor: { to: 'page', edge: 'top-left' }, size: { width: 'fill', height: mm(13) } } },
  text('journal', JOURNAL, COND, 9, { ...white, placement: at('page', 'top-left', INNER, 5) }),
  text('issue', '{attr.issue}', COND, 9, { ...white, align: 'right',
    placement: at('page', 'top-right', -OUTER, 5, 60) }),
  text('kind', '{attr.kind}', COND, 8.5, { ...caps, color: col('accent'),
    placement: at('container', 'top-left', 0, 0, MEASURE) }),
  text('title', '{titleText}', SANS, 16, { fontWeight: 600, lineHeight: 1.18,
    placement: at('#kind', 'below', 0, 2.5, MEASURE - 6) }),
  text('authors', '{attr.authors}', SERIF, 10, { inlineMarks: true, // ^1^ → ¹
    placement: at('#title', 'below', 0, 3.5, MEASURE) }),
  text('affiliations', '{attr.affiliations}', SANS, 7.2, { inlineMarks: true, lineHeight: 1.35,
    color: col('muted'), placement: at('#authors', 'below', 0, 1.6, MEASURE) }),
  text('note', '{attr.note}', SANS, 7.2, { color: col('muted'),
    placement: at('#affiliations', 'below', 0, 2.4, MEASURE) }),
] } };
```

Το στιλ επικεφαλίδας σχεδιάζει τη ζώνη του περιοδικού, τον τύπο του άρθρου, τον τίτλο, τους συγγραφείς με τους αριθμούς των ιδρυμάτων τους και ένα σημείωμα, όλα από χαρακτηριστικά του H1. Οι δύο εκδόσεις μοιράζονται το στιλ, και το κείμενο μένει στο Markdown.

## Η πλήρης συνταγή

Ένα αρχείο, συντεθειμένο από τον φάκελο της συνταγής με το δείγμα κειμένου και το κοινό κιτ του Συνταγολογίου ενσωματωμένα· φτιάχνει τη δική του σελίδα. Για να το εκτελέσετε, βάλτε το σε ένα `<script type="module">` σε μια κενή σελίδα, ή επικολλήστε το στο πάνελ JS ενός νέου CodePen (ως module). Εισάγει το postext από το esm.sh, οπότε δεν χρειάζεται εγκατάσταση ούτε build.

- Φάκελος πηγής: https://github.com/drnachio/postext/tree/main/cookbook/clinical-paper-line-edges

### script.js

```js
// ═══ Postext Cookbook · Nº 186 · Citations and statistics off the line edges ═══════════
// https://postext.dev/en/cookbook/clinical-paper-line-edges
// Code: MIT · Text: original (CC BY 4.0) · Pictures: none
// Fonts: STIX Two Text, IBM Plex Sans and Sans Condensed (SIL OFL 1.1) · Needs postext ≥ 1.79.0
import {
  buildDocumentWithFonts, renderPageToCanvas, registerCitationEngine,
} from 'https://esm.sh/postext';
import { createCiteprocEngine, STYLES, LOCALES } from 'https://esm.sh/postext-citeproc';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'clinical-paper-line-edges';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: an indigo journal, a pale amber band for the proof marks
const palette = { ink: '#1b1e26', accent: '#2c4a7c', tint: '#e9eef6', mark: '#f7dfa9',
  muted: '#596173', paper: '#ffffff' };
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.accent })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [SERIF, SANS, COND] = ['STIX Two Text', 'IBM Plex Sans', 'IBM Plex Sans Condensed'];
const [TRIM_W, TRIM_H, TOP, BOTTOM, INNER, OUTER, GUTTER] = [170, 240, 20, 22, 17, 15, 6];
const MEASURE = TRIM_W - INNER - OUTER; // 138 mm: two columns of 66 mm, about 45 characters
const LEAD = 12.8; // pt, for 9.5 pt type

// #region answer: no line opens on a citation, no line ends or opens on a lone sign
const bodyText = {
  fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  referenceBold: false, textAlign: 'justify', firstLineIndent: mm(3.5),
  indentAfterHeading: false, hyphenation: { enabled: true },
  optimalLineBreaking: true, // the rules price breaks in the Knuth–Plass breaker
  avoidWidows: true, avoidOrphans: true, avoidRunts: true,
  // A line that opens on a citation, "[8, 9]" (citationBreak), or ends or opens on a sign
  // set between spaces, "p <" / "0.05" (operatorBreak). 'warn' reports each one and changes
  // nothing; 'avoid' adds the penalty to the demerits of those breaks and reports the ones
  // it keeps. The first proof sets 'warn' (see proofs).
  citationBreaks: 'avoid', operatorBreaks: 'avoid',
  // 10000 by default, what a line spaced to the limit costs. A 66 mm column offers few other
  // breaks; at 30000 the breaker takes looser lines, never past maxWordSpacing.
  citationBreakPenalty: 30000, operatorBreakPenalty: 30000,
};
// #endregion

// #region citations: numbered references in brackets, the list in the Vancouver order
registerCitationEngine(createCiteprocEngine({ styles: STYLES, locales: LOCALES }));
const citations = { style: 'elsevier-vancouver', locale: t({ en: 'en-GB', es: 'es-ES' }),
  marker: 'brackets', collapseRanges: true, // [8, 9] and [4–6], set after a word space
  bibliography: { fontSize: em(0.8), lineHeight: pt(9.6), entrySpacing: pt(1),
    labelWidth: mm(6), labelAlign: 'right', doi: 'hide' } };
// #endregion

// #region title: the masthead band, article type, title, authors and the note
const text = (id, content, family, size, extra) => ({ kind: 'text', id, content, align: 'left',
  fontFamily: family, fontSize: pt(size), color: col('ink'), overflow: 'wrap', ...extra });
const at = (to, edge, x, y, width) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
  ...(width && { size: { width: mm(width), height: 'auto' } }) });
const caps = { fontFamily: COND, fontWeight: 600, letterSpacing: pt(1.2),
  textTransform: 'uppercase' };
const JOURNAL = t({ en: 'Ribera Paediatric Journal', es: 'Revista Pediátrica de la Ribera' });
const white = { ...caps, color: col('paper') };
const titleBlock = { enabled: true, minHeight: mm(58), slot: { elements: [
  { kind: 'box', id: 'band', style: { backgroundColor: col('accent') }, placement: {
    anchor: { to: 'page', edge: 'top-left' }, size: { width: 'fill', height: mm(13) } } },
  text('journal', JOURNAL, COND, 9, { ...white, placement: at('page', 'top-left', INNER, 5) }),
  text('issue', '{attr.issue}', COND, 9, { ...white, align: 'right',
    placement: at('page', 'top-right', -OUTER, 5, 60) }),
  text('kind', '{attr.kind}', COND, 8.5, { ...caps, color: col('accent'),
    placement: at('container', 'top-left', 0, 0, MEASURE) }),
  text('title', '{titleText}', SANS, 16, { fontWeight: 600, lineHeight: 1.18,
    placement: at('#kind', 'below', 0, 2.5, MEASURE - 6) }),
  text('authors', '{attr.authors}', SERIF, 10, { inlineMarks: true, // ^1^ → ¹
    placement: at('#title', 'below', 0, 3.5, MEASURE) }),
  text('affiliations', '{attr.affiliations}', SANS, 7.2, { inlineMarks: true, lineHeight: 1.35,
    color: col('muted'), placement: at('#authors', 'below', 0, 1.6, MEASURE) }),
  text('note', '{attr.note}', SANS, 7.2, { color: col('muted'),
    placement: at('#affiliations', 'below', 0, 2.4, MEASURE) }),
] } };
// #endregion

const small = { fontFamily: SANS, fontSize: pt(7.8), lineHeight: pt(10.6), textAlign: 'left',
  firstLineIndent: pt(0), color: col('ink'), boldColor: col('accent') };
const box = (id, spaced, more) => ({ id, border: { enabled: false }, snapToGrid: false,
  background: col('tint'), padding: mm(3), marginTop: pt(LEAD / 2), marginBottom: pt(LEAD),
  titleStyle: { ...caps, fontSize: pt(8), color: col('accent') },
  body: { ...small, paragraphSpacing: spaced }, ...more });
const calloutStyles = [box('abstract', true, { marginTop: pt(0) }), box('slip', false,
  { stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') } })];
const head = (id, content, parity, edge, x, extra) => text(id, content, COND, 7.8, {
  parity, pages: 'body', fontWeight: 500, letterSpacing: pt(0.4), color: col('muted'),
  overflow: 'clip', placement: at('page', edge, x, 11, 100), ...extra });
const [folio, right] = [{ fontWeight: 600, color: col('accent') }, { align: 'right' }];
const header = { elements: [
  head('v-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
  head('v-title', '{attr.verso}', 'even', 'top-left', OUTER + 9), // the H1's attributes
  head('r-title', '{attr.recto}', 'odd', 'top-right', -OUTER - 9, right),
  head('r-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, { ...folio, ...right }),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'bottom-right', -OUTER,
  { ...folio, ...right, pages: 'opener', placement: at('page', 'bottom-right', -OUTER, -12, 10) },
)] };

const sans = (size) => ({ fontFamily: SANS, fontSize: pt(size), fontWeight: 600 });
const config = {
  locale: t({ en: 'en-gb', es: 'es' }),
  colorPalette, citations, calloutStyles, header, footer, bodyText,
  checks: { contentInConfig: { allow: [JOURNAL] } }, // the journal's name (#849)
  headingStyles: [{ id: 'article', numbered: false, span: 'page', advancedDesign: titleBlock },
    { id: 'back', numbered: false, ...sans(9), color: col('ink') }],
  page: { sizePreset: 'custom', width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
    pageNumbering: { startAt: 211 }, // the article opens on page 211 of the issue
    margins: { top: mm(TOP), bottom: mm(BOTTOM), left: mm(INNER), right: mm(OUTER),
      mirror: true } },
  layout: { layoutType: 'double', gutterWidth: mm(GUTTER) },
  headings: { fontFamily: SANS, color: col('accent'), fontWeight: 600, levels: [
    { level: 1, breakBefore: { enabled: true, parity: 'any' } },
    { level: 2, ...sans(10.5), lineHeight: pt(LEAD), marginTop: pt(LEAD), marginBottom: pt(0) },
    { level: 3, ...sans(9), color: col('ink'), lineHeight: pt(LEAD), marginTop: pt(LEAD / 2),
      marginBottom: pt(0) },
  ] },
  paragraphStyles: [{ id: 'info', ...small }], // the article information, as journals set it
  markStyles: [{ id: 'edge', name: t({ en: 'Line edge', es: 'Borde de línea' }), color: col('ink'),
    background: col('mark'), paddingX: em(0.08), paddingTop: em(0.02), paddingBottom: em(0.08) }],
};

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = String.raw`---
title: "Lung ultrasound for pneumonia in children"
author: "Inés Barreiro Soto, Tomasz Wierzbicki, Aisha Mensah and Pablo Lago Fernández"
---

# Point-of-care lung ultrasound for community-acquired pneumonia in children: a prospective diagnostic accuracy study {style="article" issue="2026 · 9(4) · 211–213" verso="Ribera Paediatr J 2026;9(4)" recto="Barreiro Soto et al. · Lung ultrasound for pneumonia" kind="Original research" authors="Inés Barreiro Soto^1^, Tomasz Wierzbicki^2^, Aisha Mensah^1^, Pablo Lago Fernández^3^" affiliations="^1^ Paediatric Emergency Department, Hospital Comarcal de la Ribera\n^2^ Department of Radiology, Hospital Comarcal de la Ribera\n^3^ Clinical Epidemiology Unit, Ribera Health Area" note="Illustrative article written for the Postext Cookbook: the study, its authors and its data are invented. The works cited are real."}

:::callout{type="abstract" title="Abstract"}
**Objective** To find out how accurately emergency paediatricians diagnose community-acquired pneumonia in children with lung ultrasound, against chest radiography read by two radiologists and a review on day 14.

**Methods** We enrolled 412 children aged 3 months to 15 years who came to one emergency department with fever and cough or fast breathing. One of nine paediatricians scanned each child before the radiograph, after a six-hour course.

**Results** Pneumonia was diagnosed in 139 children (33.7%). Ultrasound had a sensitivity of 91.4% (95% CI 85.5 to 95.0) and a specificity of 95.2% (92.0 to 97.2), so LR+ = 19.19 and LR− = 0.09. A median scan took 6 minutes.

**Conclusions** After a short course, emergency paediatricians rule pneumonia in or out with ultrasound about as well as a radiograph does, and without radiation.
:::

## Introduction

Pneumonia is the commonest serious infection of childhood and the reason for many of the chest radiographs taken in children’s emergency departments. British guidelines advise against a routine radiograph in a child well enough to go home [@harris2011], yet the film is often asked for to settle a doubtful examination, and two radiologists reading the same film do not always agree.

Lung ultrasound looks at the same disease through another window. Consolidated lung carries sound and shows as a solid, liver-like area with bright air bronchograms, signs that were described and standardised in adults first [@lichtenstein2008; @volpicelli2012]. In children the thin chest wall makes the scan easier, and a meta-analysis and a large prospective study found it both sensitive and specific [@pereda2015; @shah2013]. Most of those scans, however, were done by sonographers or by a few physicians with long experience, and it is not known whether the figures hold when the scan is one task among many on a night shift.

We measured the accuracy of lung ultrasound done by the emergency paediatricians of a district hospital after a short course, and report it as STARD 2015 asks [@bossuyt2015].

## Methods

### Participants

From 1 October 2024 to 30 November 2025 we approached children aged 3 months to 15 years who came to the emergency department of a district hospital of 280 beds with a temperature of 38 °C or more and cough, fast breathing or chest indrawing. Children with chronic lung disease, congenital heart disease or a radiograph taken elsewhere in the previous week were not included. Parents gave written consent, and the regional ethics committee approved the protocol. Data were entered in REDCap [@harris2009].

### Index test

Nine paediatricians, none of whom had used lung ultrasound before, attended a course of six hours, two of them spent scanning under supervision. Each scan covered six zones on each side of the chest with a linear probe of 8 to 12 MHz and was recorded as positive when a consolidation of 1 cm or more with air bronchograms was seen under the pleura. The scan was done before the radiograph, and the paediatrician entered the result before seeing the film.

### Reference standard

Two radiologists who did not know the ultrasound result read every radiograph, and a third settled disagreements. The final diagnosis joined the agreed reading to a telephone review on day 14, as STARD advises when no single test is a gold standard [@bossuyt2015]. A child with a normal film who was given antibiotics for pneumonia by the family doctor within the 14 days was counted as having pneumonia.

### Statistical analysis

Sensitivity and specificity are given with Wilson intervals [@newcombe1998], and likelihood ratios with the intervals of Simel and colleagues [@simel1991]. We read a positive likelihood ratio above 10, or a negative one below 0.1, as a large change in the probability of disease [@altman1994; @deeks2004]. Agreement was measured with Cohen’s kappa and read on the scale of Landis and Koch [@landis1977]. We planned 400 children, so that with a prevalence of one in three the lower limit of the interval for a sensitivity of 90% would stay above 83%. A value of p < 0.05 was taken as significant.

## Results

Of 451 children screened, 412 were enrolled. Their mean age was 4.1 ± 3.2 years, 221 (53.6%) were boys and 97 (23.5%) were under 2 years. Pneumonia was diagnosed in 139 (33.7%), 14 of them only at the review on day 14.

Ultrasound was positive in 140 children and right in 127 of them. Its sensitivity was 91.4% (95% CI 85.5 to 95.0) and its specificity 95.2% (92.0 to 97.2), with a positive predictive value of 90.7% and a negative predictive value of 95.6%. The likelihood ratios were LR+ = 19.19 and LR− = 0.09, both past the limits set in advance. Sensitivity was lower in children under 2 years, 31 of 35 (88.6%), than in older children, 96 of 104 (92.3%), a difference of the size chance would give (p = 0.51). Sensitivity also rose with practice, from 87.5% in each paediatrician’s first 20 scans to 94.0% after them (p = 0.18).

The 12 false negatives were consolidations under 1 cm on the film (7), shadows behind the heart (3) and two films read as pneumonia by both radiologists in children whose fever settled without antibiotics. In a logistic model, a consolidation under 1 cm on the film was the only factor linked to a missed diagnosis (OR = 6.2, 95% CI 2.1 to 18.4; p < 0.001); an age under 2 years was not (OR = 1.6; p = 0.43). Between the paediatricians and an expert who reviewed 120 stored clips, kappa = 0.84; between the two radiologists, kappa = 0.71. The median scan took 6 minutes (interquartile range 4 to 8), and no child needed sedation.

## Discussion

With six hours of training, emergency paediatricians diagnosed pneumonia with ultrasound about as accurately as the experienced operators of earlier studies [@pereda2015; @shah2013], and agreed with an expert more closely than the radiologists agreed with each other. With LR+ = 19.19, a positive scan in a child whose pre-test probability is one in three raises it above 90%, and with LR− = 0.09 a negative scan brings it under 5%.

The false negatives show where the scan is weak: small consolidations and the lung behind the heart, which the probe cannot reach between the ribs. They also show the weakness of the reference standard, since two of them were probably shadows on the film. The study has other limits. It was done in one hospital, the paediatricians volunteered for the course, and a review by telephone on day 14 will have missed some mild cases.

The scan suits the place where the decision is taken. A child who would otherwise be sent to radiology can be scanned in the cubicle, and the radiograph kept for the child whose scan is doubtful or whose fever does not settle as expected.

## Article information {style="back"}

:::paragraphs{style="info"}
**Funding** None. **Competing interests** None declared. **Note** Set in STIX Two Text, IBM Plex Sans and IBM Plex Sans Condensed (SIL OFL). Text: original, CC BY 4.0. The study, its authors, the hospital and the results are invented for this example; the references are to real published works.
:::

## References {style="back"}

:::bibliography{title=""}

:::references{format=bibtex}
@article{harris2011,
  author = {Harris, Michael and Clark, Julia and Coote, Nicky and Fletcher, Penny and Harnden, Anthony and McKean, Michael and Thomson, Anne},
  title = {British Thoracic Society guidelines for the management of community acquired pneumonia in children: update 2011},
  journal = {Thorax}, year = 2011, volume = 66, number = {Suppl 2}, pages = {ii1--ii23}}
@article{landis1977,
  author = {Landis, J. Richard and Koch, Gary G.},
  title = {The measurement of observer agreement for categorical data},
  journal = {Biometrics}, year = 1977, volume = 33, number = 1, pages = {159--174}}
@article{lichtenstein2008,
  author = {Lichtenstein, Daniel A. and Mezière, Gilbert A.},
  title = {Relevance of lung ultrasound in the diagnosis of acute respiratory failure: the {BLUE} protocol},
  journal = {Chest}, year = 2008, volume = 134, number = 1, pages = {117--125}}
@article{volpicelli2012,
  author = {Volpicelli, Giovanni and Elbarbary, Mahmoud and Blaivas, Michael and Lichtenstein, Daniel A. and Mathis, Gebhard and Kirkpatrick, Andrew W. and Melniker, Lawrence},
  title = {International evidence-based recommendations for point-of-care lung ultrasound},
  journal = {Intensive Care Med}, year = 2012, volume = 38, number = 4, pages = {577--591}}
@article{pereda2015,
  author = {Pereda, Maria A. and Chavez, Miguel A. and Hooper-Miele, Christine C. and Gilman, Robert H. and Steinhoff, Mark C. and Ellington, Laura E. and Gross, Margaret},
  title = {Lung ultrasound for the diagnosis of pneumonia in children: a meta-analysis},
  journal = {Pediatrics}, year = 2015, volume = 135, number = 4, pages = {714--722}}
@article{shah2013,
  author = {Shah, Vaishali P. and Tunik, Michael G. and Tsung, James W.},
  title = {Prospective evaluation of point-of-care ultrasonography for the diagnosis of pneumonia in children and young adults},
  journal = {JAMA Pediatr}, year = 2013, volume = 167, number = 2, pages = {119--125}}
@article{bossuyt2015,
  author = {Bossuyt, Patrick M. and Reitsma, Johannes B. and Bruns, David E. and Gatsonis, Constantine A. and Glasziou, Paul P. and Irwig, Les and Lijmer, Jeroen G.},
  title = {{STARD} 2015: an updated list of essential items for reporting diagnostic accuracy studies},
  journal = {BMJ}, year = 2015, volume = 351, pages = {h5527}}
@article{harris2009,
  author = {Harris, Paul A. and Taylor, Robert and Thielke, Robert and Payne, Jonathon and Gonzalez, Nathaniel and Conde, Jose G.},
  title = {Research electronic data capture ({REDCap}): a metadata-driven methodology and workflow process for providing translational research informatics support},
  journal = {J Biomed Inform}, year = 2009, volume = 42, number = 2, pages = {377--381}}
@article{newcombe1998,
  author = {Newcombe, Robert G.},
  title = {Two-sided confidence intervals for the single proportion: comparison of seven methods},
  journal = {Stat Med}, year = 1998, volume = 17, number = 8, pages = {857--872}}
@article{simel1991,
  author = {Simel, David L. and Samsa, Gregory P. and Matchar, David B.},
  title = {Likelihood ratios with confidence: sample size estimation for diagnostic test studies},
  journal = {J Clin Epidemiol}, year = 1991, volume = 44, number = 8, pages = {763--770}}
@article{altman1994,
  author = {Altman, Douglas G. and Bland, J. Martin},
  title = {Diagnostic tests 1: sensitivity and specificity},
  journal = {BMJ}, year = 1994, volume = 308, number = 6943, pages = {1552}}
@article{deeks2004,
  author = {Deeks, Jonathan J. and Altman, Douglas G.},
  title = {Diagnostic tests 4: likelihood ratios},
  journal = {BMJ}, year = 2004, volume = 329, number = 7458, pages = {168--169}}
:::
`;

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { 'STIX Two Text': ['400', '400i', '600'], 'IBM Plex Sans': ['400', '600'],
  'IBM Plex Sans Condensed': ['500', '600'] };

// ─── 4 · Build & show ───────────────────────────────────────────────────────
// #region marks: each break a build reported, marked in the source of the second build
// The word before the citation and the citation, or the sign and the number on its other
// side, wrapped in :mark[…]: a band under ordinary text, so the breaks stay where they were.
const wordEnd = (s, i) => i + s.slice(i).search(/[\s;)]|[,.](?!\d)|$/); // 0.09, not 0
function sides(source, w, a, b) { // a warning names line a, before the break, by its source
  if (w.kind === 'citationBreak') { // "colleagues [@simel1991]"
    const cite = source.lastIndexOf('[@', b.sourceStart + 2);
    return [source.lastIndexOf(' ', cite - 2) + 1, source.indexOf(']', cite) + 1];
  }
  if (w.edge === 'end') { // "LR− = 0.09": the sign ends line a, the number opens line b
    const from = source.lastIndexOf(` ${w.text} `, a.sourceEnd) + 1;
    return [from, wordEnd(source, from + w.text.length + 1)];
  }
  const sign = source.indexOf(` ${w.text} `, b.sourceStart - 1); // the sign opens line b
  return [source.lastIndexOf(' ', sign - 1) + 1, sign + 1 + w.text.length];
}
function markBreaks(source, doc, found) {
  const pairs = doc.blocks.flatMap((b) => b.lines.map((line, i) => [line, b.lines[i + 1]]));
  const spans = new Map();
  for (const w of found) {
    const [a, b] = pairs.find(([line]) => line.sourceStart === w.sourceStart) ?? [];
    const [from, to] = b ? sides(source, w, a, b) : [];
    if (from > a?.sourceStart && to > from && to <= b.sourceEnd) spans.set(from, to);
  }
  return [...spans].sort(([x], [y]) => y - x).reduce((md, [from, to]) => `${md.slice(0, from)}`
    + `:mark[${md.slice(from, to)}]{style="edge"}${md.slice(to)}`, source);
}
// #endregion

// #region proofs: the same article twice, 'warn' then 'avoid', each with a query slip
const KIND = { citationBreak: t({ en: 'citation', es: 'cita' }),
  operatorBreak: t({ en: 'sign', es: 'signo' }) };
const edge = (s, end) => (end ? s.trim().split(/\s+/).slice(-2) : s.trim().split(/\s+/)
  .slice(0, 2)).join('\u00a0').replace(/[.,;]$/, ''); // no-break spaces: no breaks of its own
const query = (doc, w) => `${t({ en: 'p.', es: 'pág.' })}\u00a0${doc.pages[w.pageIndex]
  .pageLabel}, ${KIND[w.kind]}: …${edge(w.lines[0], true)}\u00a0/ ${edge(w.lines[1])}…`;
const slip = (mode, doc, found) => ['', `:::callout{type="slip" title="${mode === 'warn'
  ? t({ en: 'First proof: queries', es: 'Primeras pruebas: consultas' })
  : t({ en: 'Second proof: queries', es: 'Segundas pruebas: consultas' })}"}`,
`citationBreaks / operatorBreaks: '${mode}' · ${found.length} ${found.length === 1
  ? t({ en: 'break', es: 'corte' }) : t({ en: 'breaks', es: 'cortes' })}.`,
...found.flatMap((w) => ['', query(doc, w)]), ':::', ''].join('\n');
const build = (md, mode) => buildDocumentWithFonts({ markdown: md }, { ...config,
  bodyText: { ...bodyText, citationBreaks: mode, operatorBreaks: mode } }, kitFonts(FONTS));
async function proof(mode) {
  const plain = await build(markdown, mode); // pass 1: where the breaks are
  const found = (plain.contentWarnings ?? []).filter((w) => /^(citation|operator)Break$/
    .test(w.kind));
  return build(markBreaks(markdown, plain, found) + slip(mode, plain, found), mode); // pass 2
}
const docs = { warn: await proof('warn'), avoid: await proof('avoid') };
// #endregion

const TITLE = t({ en: 'Citations and statistics off the line edges',
  es: 'Citas y estadísticos fuera de los bordes de línea' });
const show = (key) => showPages(docs[key], { title: `${TITLE} · '${key}'` });
const button = (key) => Object.assign(document.createElement('button'),
  { type: 'button', textContent: key, onclick: () => show(key) });
document.getElementById('pt-actions').prepend(button('warn'), button('avoid'));
show('warn');

// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ─────

// ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook
function mm(value) { return { value, unit: 'mm' }; }
function pt(value) { return { value, unit: 'pt' }; }
function em(value) { return { value, unit: 'em' }; }
/** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */
function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; }
/** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */
function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; }

// ─── Kit · fonts v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,'
      + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
    'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,'
      + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}files/${id}-${subset}-${weight}-${style}.woff2`;
        const face = new FontFace(family, `url(${url}) format('woff2')`,
          { weight: String(weight), style, unicodeRange: ranges[subset] });
        jobs.push(face.load().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
function hasFace(family, weight, style) {
  for (const face of document.fonts) {
    if (face.status !== 'loaded' || face.style !== style) continue;
    if (face.family.replace(/^["']|["']$/g, '') !== family) continue;
    const [low, high = low] = face.weight.split(' ').map(Number);
    if (weight >= low && weight <= high) return true;
  }
  return false;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  const root = viewer(title);
  const pages = [docs].flat().flatMap((doc) =>
    doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index })));
  const spreads = [];
  let verso = null;
  for (const p of pages) {
    if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; }
    else { spreads.push([verso, p]); verso = null; }
  }
  if (verso) spreads.push([verso, null]);
  const density = Math.min(window.devicePixelRatio || 1, 2);
  showPages.painter?.disconnect();
  const painter = new IntersectionObserver((entries) => {
    for (const { isIntersecting, target } of entries) {
      if (!isIntersecting) continue;
      painter.unobserve(target);
      const { doc, page } = target.postext;
      renderPageToCanvas(page, doc, target, { ...render, scale: (width * density) / page.width });
    }
  }, { rootMargin: '800px' });
  showPages.painter = painter;
  root.replaceChildren(...spreads.map((pair) => {
    const spread = document.createElement('div');
    spread.className = 'pt-spread';
    for (const p of pair) {
      const figure = document.createElement('figure');
      if (p) {
        const label = p.page.pageLabel || String(p.n + 1);
        const canvas = document.createElement('canvas');
        canvas.postext = p;
        canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`;
        canvas.setAttribute('role', 'img');
        canvas.setAttribute('aria-label', `Page ${label}`);
        const folio = document.createElement('figcaption');
        folio.textContent = label;
        figure.append(canvas, folio);
        painter.observe(canvas);
      } else figure.className = 'pt-blank';
      spread.append(figure);
    }
    return spread;
  }));
  kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`);
  document.documentElement.dataset.postext = 'ready';
  return pages.length;
}

/** The desk, the bar and the error reporting, created once. */
function viewer(title) {
  if (!document.getElementById('pt-kit')) {
    document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit">
      :root { color-scheme: dark; }
      body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; }
      #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center;
        gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px);
        border-bottom: 1px solid #23262d; }
      #pt-bar strong { color: #f4f1ea; font-weight: 600; }
      #pt-actions { display: flex; gap: 12px; margin-left: auto; }
      #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
      #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; }
      .pt-spread { display: flex; }
      .pt-spread figure { margin: 0; width: min(460px, 44vw); }
      .pt-spread canvas { display: block; width: 100%; background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif;
        letter-spacing: .18em; text-transform: uppercase; color: #6c7079; }
      .pt-blank { visibility: hidden; }
      @media (max-width: 760px) {
        .pt-spread { flex-direction: column; gap: 32px; }
        .pt-spread figure { width: min(460px, 92vw); }
        .pt-blank { display: none; }
      }
    </style>`);
    document.body.insertAdjacentHTML('afterbegin',
      '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>');
    document.getElementById('pt-title').textContent = document.title || 'Postext';
    addEventListener('error', (event) => kitFail(event.error ?? event.message));
    addEventListener('unhandledrejection', (event) => kitFail(event.reason));
  }
  if (title) document.getElementById('pt-title').textContent = title;
  return document.getElementById('pages')
    ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' }));
}

function kitStatus(text) {
  viewer();
  document.getElementById('pt-status').textContent = text;
}

function kitFail(error) {
  document.documentElement.dataset.postext = 'error';
  kitStatus(`Error: ${error?.message ?? error}`);
}

// ─── /Kit ───────────────────────────────────────────────────────────────────────
```

## Παραλλαγές

### Αναφέρετε τις αλλαγές γραμμής χωρίς να αλλάξετε τίποτα

Ένα περιοδικό που ελέγχει τα δοκίμιά του με το χέρι μπορεί να κρατήσει τον κανόνα σε `'warn'`: το Sandbox απαριθμεί κάθε αλλαγή γραμμής στους Ελέγχους, και οι γραμμές μένουν όπως τις στοιχειοθέτησε ο αλγόριθμος.

```diff
-  citationBreaks: 'avoid', operatorBreaks: 'avoid',
+  citationBreaks: 'warn', operatorBreaks: 'warn',
```

### Κρατήστε την προεπιλεγμένη ποινή

Στα 10000 τα διαστήματα μένουν λίγο πιο σφιχτά και μένουν δύο αλλαγές γραμμής σε κάθε έκδοση αντί για μία.

```diff
-  citationBreakPenalty: 30000, operatorBreakPenalty: 30000,
```

## Συνήθη λάθη

- **Προειδοποίηση σελιδοποίησης: Παραπομπή στην αρχή γραμμής** (`citationBreak`). Μια γραμμή παραγράφου αρχίζει με αριθμημένη βιβλιογραφική παραπομπή που ακολουθεί μια λέξη ή με κομμάτι της: «συγγραφείς» στο τέλος μιας γραμμής και «[12]» στην αρχή της επόμενης, ή «[14,» πάνω από «16]». Ένας αριθμός σε αγκύλες ή παρενθέσεις μετά από αριθμό δεν είναι παραπομπή («2016 (3)»), ούτε μια λέξη σε αγκύλες. Το δεξιόστροφο κείμενο και το κινεζικό, ιαπωνικό ή κορεατικό κείμενο μένουν ανέγγιχτα. Με το bodyText.citationBreaks σε 'warn' αναφέρεται κάθε τέτοια αλλαγή· σε 'avoid', όσες κράτησε ο αλγόριθμος αλλαγής γραμμής επειδή καμία στοιχειοθέτηση μέσα στα όρια του διαστήματος λέξεων δεν τις απέφευγε με κόστος μικρότερο από bodyText.citationBreakPenalty. Η μηχανή καταγράφει την καθεμία στο doc.contentWarnings με την παραπομπή, τις δύο γραμμές και τη σελίδα τους. Διόρθωση: Ορίστε το bodyText.citationBreaks σε 'avoid': ο αλγόριθμος αλλαγής γραμμής κοστολογεί μια αλλαγή πριν από ή μέσα σε παραπομπή και στοιχειοθετεί αλλιώς την παράγραφο όπου το επιτρέπει το διάστημα λέξεων· το διάστημα εξακολουθεί να τεντώνεται μαζί με τα άλλα. Μια αλλαγή που μένει κοστίζει περισσότερο από το bodyText.citationBreakPenalty για να αποφευχθεί, συχνά επειδή η παραπομπή είναι φαρδιά για το πλάτος στοιχειοθεσίας: αυξήστε την ποινή για να την ανταλλάξετε με πιο αραιές γραμμές ή γράψτε ένα αδιάσπαστο διάστημα (U+00A0) ανάμεσα στη λέξη και την παραπομπή για να δέσετε αυτό το ζεύγος ανεξάρτητα από τον κανόνα. Στη μεταφορά ενός υπάρχοντος βιβλίου κρατήστε το 'warn': η μεταφορά αναπαράγει τις αλλαγές γραμμής του πρωτοτύπου. ([Τεκμηρίωση](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο))
- **Προειδοποίηση σελιδοποίησης: Σύμβολο στο άκρο γραμμής** (`operatorBreak`). Μια γραμμή παραγράφου τελειώνει ή αρχίζει με ένα μεμονωμένο σύμβολο ανάμεσα σε διαστήματα, ένα από τα = < > ≤ ≥ ± × ≈ ≠ ÷ − + · →: «LR+ =» στο τέλος μιας γραμμής με «18,29» στην επόμενη, ή «± 0,03» στην αρχή μιας γραμμής. Ένα ενωτικό ανάμεσα σε λέξεις δεν είναι σύμβολο. Το δεξιόστροφο κείμενο και το κινεζικό, ιαπωνικό ή κορεατικό κείμενο μένουν ανέγγιχτα. Με το bodyText.operatorBreaks σε 'warn' αναφέρεται κάθε τέτοια αλλαγή, μία ανά αλλαγή (μια γραμμή που αρχίζει και τελειώνει με σύμβολο δίνει δύο)· σε 'avoid', όσες κράτησε ο αλγόριθμος αλλαγής γραμμής επειδή καμία στοιχειοθέτηση μέσα στα όρια του διαστήματος λέξεων δεν τις απέφευγε με κόστος μικρότερο από bodyText.operatorBreakPenalty. Η μηχανή καταγράφει την καθεμία στο doc.contentWarnings με το σύμβολο, το άκρο (end ή start), τις δύο γραμμές και τη σελίδα τους. Διόρθωση: Ορίστε το bodyText.operatorBreaks σε 'avoid': ο αλγόριθμος αλλαγής γραμμής κοστολογεί μια αλλαγή στα διαστήματα εκατέρωθεν του συμβόλου και στοιχειοθετεί αλλιώς την παράγραφο όπου το επιτρέπει το διάστημα λέξεων. Μια αλλαγή που μένει κοστίζει περισσότερο από το bodyText.operatorBreakPenalty για να αποφευχθεί, συχνά σε στενή στήλη όπου το σύμβολο και οι δύο όροι του είναι φαρδιοί: αυξήστε την ποινή για να την ανταλλάξετε με πιο αραιές γραμμές ή γράψτε αδιάσπαστα διαστήματα (U+00A0, ή U+202F για λεπτό) γύρω από το σύμβολο για να το δέσετε ανεξάρτητα από τον κανόνα. Στη μεταφορά ενός υπάρχοντος βιβλίου κρατήστε το 'warn': η μεταφορά αναπαράγει τις αλλαγές γραμμής του πρωτοτύπου. ([Τεκμηρίωση](https://postext.dev/el/docs/configuration-text.md#κυρίως-κείμενο))

- Οι αλλαγές γραμμής εντοπίζονται στις γραμμές όπως έχουν σπάσει. Μια αλλαγή στη διάσταση σελίδας, στο μέγεθος ή στο κείμενο τις μετακινεί, οπότε διαβάστε τις προειδοποιήσεις κάθε δημιουργίας αντί να αντιγράφετε θέσεις από μια προηγούμενη.
- Για να κρατήσετε μία παραπομπή με τη λέξη της όποια κι αν είναι η στήλη, πληκτρολογήστε ένα αδιάσπαστο διάστημα πριν από αυτήν στο Markdown. Ο κανόνας κάνει τα υπόλοιπα στο άρθρο.

## Ευχαριστίες

- Συνταγή: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Γραμματοσειρές: STIX Two Text (OFL-1.1), IBM Plex Sans (OFL-1.1), IBM Plex Sans Condensed (OFL-1.1)
- Κώδικας: MIT · Δείγμα περιεχομένου: CC-BY-4.0

## Σχετικές συνταγές

- [Αρ. 184 · Πεζό με πλήρη στοίχιση χωρίς στοίβες λέξεων στις άκρες](https://postext.dev/el/cookbook/prose-without-stacks.md): Μια σελίδα του Dickens δύο φορές σε στενό πλάτος: το πρώτο δοκίμιο αναφέρει και σημαδεύει κάθε στοίβα, το δεύτερο τις ζυγίζει στο σπάσιμο των γραμμών. · Επίπεδο 2 (Μεσαίο) · Πεζογραφία, θέατρο και λογοτεχνικός λόγος
- [Αρ. 095 · Ένα ιατρικό άρθρο σε στιλ Vancouver](https://postext.dev/el/cookbook/medical-article-vancouver.md): Αναφορά κλινικής δοκιμής σε A4 με δύο στήλες: ανυψωμένοι αριθμοί παραπομπών, αριθμημένη βιβλιογραφία Vancouver και DOI που ανοίγουν ως σύνδεσμοι στο PDF. · Επίπεδο 2 (Μεσαίο) · Επιστημονικά άρθρα και ακαδημαϊκά κείμενα
- [Αρ. 014 · Ομοιόμορφα κενά λέξεων σε στενές στήλες πλήρους στοίχισης](https://postext.dev/el/cookbook/justification-lab.md): Knuth–Plass με κενά λέξεων 0,8–1,6 του κανονικού, δίπλα σε άπληστη εκδοχή ελέγχου όπου το VDT σημειώνει αραιές, μοναχικές και κοντές τελευταίες γραμμές. · Επίπεδο 3 (Προχωρημένο) · Περιοδικά και fanzines
