# 三栏的希腊语日报头版

> 希腊语头版：Didot报头，不带tonos的大写主标题，三行首字下沉加大写引词，底部一栏简讯。

- HTML版本: https://postext.dev/zh/cookbook/greek-daily-front-page
- 食谱 No. 204 · 页面与网格 · 难度 2 (中级) · 输出: Canvas, PDF
- 体裁: 报纸与通讯
- 需要 postext ≥ 1.99.1, postext-pdf ≥ 1.99.1 · 已用 1.99.1, postext-pdf 1.99.1 测试，日期 2026-11-29
- 页面: [1](https://postext.dev/cookbook/greek-daily-front-page/en/p01.webp?v=a90d97d9)
- PDF: https://postext.dev/cookbook/greek-daily-front-page/en/greek-daily-front-page.pdf?v=a90d97d9
- 在沙盒中打开: https://postext.dev/zh/sandbox#recipe=greek-daily-front-page&lang=en (.postext: https://postext.dev/cookbook/greek-daily-front-page/en/greek-daily-front-page.postext)
- 最后更新: 2026-11-29
- 其他语言: [en](https://postext.dev/en/cookbook/greek-daily-front-page.md), [es](https://postext.dev/es/cookbook/greek-daily-front-page.md), [ca](https://postext.dev/ca/cookbook/greek-daily-front-page.md), [de](https://postext.dev/de/cookbook/greek-daily-front-page.md), [el](https://postext.dev/el/cookbook/greek-daily-front-page.md), [fr](https://postext.dev/fr/cookbook/greek-daily-front-page.md), [it](https://postext.dev/it/cookbook/greek-daily-front-page.md), [pt](https://postext.dev/pt/cookbook/greek-daily-front-page.md), [ja](https://postext.dev/ja/cookbook/greek-daily-front-page.md), [ar](https://postext.dev/ar/cookbook/greek-daily-front-page.md)

## 简单来说

一份虚构希腊地方报纸的头版：顶部是报名，下面是大写的大标题，头条分三栏、以一个大字母开头，还有小地图、船班时刻表和底部的简讯。

## 成品一览

《Ο Φάρος》（《灯塔报》）的头版，这是一个虚构港口小城的虚构日报，开本246 × 328 mm。报头用GFS Didot，左右两侧是报耳；头条在两行窄体大写标题和导语下面，分三栏Noto Serif排，栏间有细线，从三行下沉的首字母开始。一栏宽的海湾地图放在中间一栏。第二条新闻配船班时刻表，还有一条自成三栏的简讯带，收住全页。全部文字都是原创希腊语；末尾的出版说明随版本语言变化。

**这份食谱回答的问题:**

- 怎样排希腊报纸头版，让标题用大写并加首字下沉？
- 怎样给章首页加作者行、提要或带首字下沉的导语？
- 怎样让章标题横跨页面，下面的正文分两栏排？
- 怎样让西班牙文、法文或德文获得良好的两端对齐和断词？

## 简短回答

```js
// script.js, 行 39–51
// locale 'el' hyphenates the narrow columns with the monotonic patterns and makes every
// capital setting drop the tonos: the lead headline is written «Ο φάρος του Αγίου Νικολάου
// ανάβει ξανά» in the Markdown and printed ΑΝΑΒΕΙ ΞΑΝΑ, never ΑΝΆΒΕΙ.
const LOCALE = 'el';
const layout = { layoutType: 'multiple', columnCount: 3, gutterWidth: mm(5),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
const headline = { id: 'lead', fontSize: pt(30), lineHeight: pt(34), fontWeight: 800,
  textTransform: 'uppercase', letterSpacing: em(0.01), marginBottom: pt(6) };
// :::paragraphs{style="lede"} opens the story: a drop cap three lines deep and its first
// four words in capitals, which drop the tonos the same way (ΜΕ ΜΙΑ ΓΙΟΡΤΗ).
const lede = { id: 'lede', firstLineIndent: pt(0),
  dropCap: { lines: 3, fontFamily: NAME, color: col('aegean'), gap: mm(1.2),
    leadIn: { words: 4, uppercase: true } } };
```

## 用料

**讲解**

- [正文段落的首字下沉](https://postext.dev/zh/docs/configuration-text.md#首字下沉): 在标题级别、标题样式或段落样式上设置dropCap，正文段落就以放大的首字开头，首字旁的几行缩短并与正文一起排；可做凸起首字、悬挂或随首字放大的开引号，以及小型大写字母的引导词。
- [三栏及以上](https://postext.dev/zh/docs/configuration-page-layout.md#版式类型): layoutType 'multiple'把正文分成columnCount个等宽的栏（3到8栏），用于报纸和杂志；栏线、齐栏、脚注和通栏浮动体在所有栏中都适用。
- [断词与文档语言](https://postext.dev/zh/docs/justification.md#支持的语言): 基于TeX模式的九种语言断词（包括希腊语），由文档的locale选择；locale同时决定表格续表字样和带标签PDF的语言。

**还用到**

- [栏间线](https://postext.dev/zh/docs/configuration-page-layout.md#栏线)
- [横跨页面的框](https://postext.dev/zh/docs/configuration-callouts.md#callout容器)
- [框内或正文中的分栏](https://postext.dev/zh/docs/document-format-directives.md#columns)
- [浮动框](https://postext.dev/zh/docs/configuration-callouts.md#callout容器)
- [标注框](https://postext.dev/zh/docs/configuration-callouts.md#标注框样式)
- [标题样式](https://postext.dev/zh/docs/configuration-styles.md#标题样式)
- [标题属性](https://postext.dev/zh/docs/document-format.md#标题属性)
- [设计过的章首页](https://postext.dev/zh/docs/configuration-headings.md#通栏与高级设计)
- [页面设计中的文字、线条和框](https://postext.dev/zh/docs/configuration-headers-footers.md#页眉与页脚)
- [自定义资源类型](https://postext.dev/zh/docs/configuration-resources.md#资源类型)
- [由数据生成的表](https://postext.dev/zh/docs/document-format-resources.md#块级嵌入可选显式的行内放置)
- [题注样式](https://postext.dev/zh/docs/configuration-resources.md#题注样式)
- [段落样式](https://postext.dev/zh/docs/configuration-styles.md#段落样式)
- [导出PDF](https://postext.dev/zh/docs/configuration-pdf-output.md#生成pdf)
- [图就放在这里](https://postext.dev/zh/docs/document-format-resources.md#块级嵌入可选显式的行内放置)
- [通栏章首色带](https://postext.dev/zh/docs/configuration-headings.md#通栏与高级设计)
- [纸张颜色](https://postext.dev/zh/docs/configuration-page-layout.md#页面)
- [嵌入PDF的字体](https://postext.dev/zh/docs/configuration-pdf-output.md#为什么需要字体提供函数)
- [作为资源的图和表](https://postext.dev/zh/docs/document-format-resources.md#资源)
- [分节书眉](https://postext.dev/zh/docs/configuration-styles.md#标题样式)

**配置一览**

- [`bodyText`](https://postext.dev/zh/docs/configuration-text.md#正文), [`calloutStyles`](https://postext.dev/zh/docs/configuration-callouts.md#标注框样式), [`captionStyle`](https://postext.dev/zh/docs/configuration-resources.md#题注样式), [`colorPalette`](https://postext.dev/zh/docs/configuration-fonts-colors-viewers.md#调色板), [`footer`](https://postext.dev/zh/docs/configuration-headers-footers.md#页眉与页脚), [`header`](https://postext.dev/zh/docs/configuration-headers-footers.md#页眉与页脚), [`headingStyles`](https://postext.dev/zh/docs/configuration-styles.md#标题样式), [`headings`](https://postext.dev/zh/docs/configuration-headings.md#标题), [`layout`](https://postext.dev/zh/docs/configuration-page-layout.md#版式), [`locale`](https://postext.dev/zh/docs/configuration-language.md#断词), [`page`](https://postext.dev/zh/docs/configuration-page-layout.md#页面), [`paragraphStyles`](https://postext.dev/zh/docs/configuration-styles.md#段落样式), [`resourceTypes`](https://postext.dev/zh/docs/configuration-resources.md#资源类型), [`tableStyle`](https://postext.dev/zh/docs/configuration-resources.md#表格样式)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/zh/docs/configuration-programmatic-usage.md#排版前加载字体), [`decompressWoff2`](https://postext.dev/zh/docs/configuration-pdf-output.md#浏览器字体提供函数fontsource--woff2), [`registerResourceImage`](https://postext.dev/zh/docs/architecture.md#api接口), [`renderPageToCanvas`](https://postext.dev/zh/docs/configuration-programmatic-usage.md#把页面渲染为位图), [`renderToPdf`](https://postext.dev/zh/docs/configuration-pdf-output.md#生成pdf)

**字体**

- GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)

## 做法

### 1 · 三栏希腊语

代码就是上面的[简短回答](https://postext.dev/zh/cookbook/greek-daily-front-page.md#简短回答)。`layoutType: 'multiple'`加`columnCount: 3`排出三栏，栏间一条细线（[页面版式](https://postext.dev/zh/docs/configuration-page-layout.md)）。`locale: 'el'`按单调模式断词，这在69 mm的栏里很要紧，一个希腊词常占一行的三分之一。词距在正常的0.8到1.6倍之间，再加最多14‰的字距，全页只有一行超过1.6倍。

### 2 · 用小写写、印成大写的标题

标题写作«Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια»，样式设`textTransform: 'uppercase'`。在希腊语文档里大写去掉tonos，页面印出ΑΝΑΒΕΙ ΞΑΝΑ和ΥΣΤΕΡΑ，正是希腊报纸标题的写法。眉题、报耳和简讯标题也做同样的转换。

```js
// script.js, 行 55–61
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...sans(9, 700, 'aegean', { letterSpacing: pt(1.6),
    textTransform: 'uppercase' }), gap: mm(1.5) }, // the kicker, from the fence's title
  marginTop: pt(LEAD), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(17), textAlign: 'left',
    firstLineIndent: pt(0) } };
```

标题和导语放在`banner`框里，`span: 'page'`且无边框（[框](https://postext.dev/zh/docs/configuration-callouts.md)）：下面各栏从同一高度起排，第二条新闻沿用这个手法。

### 3 · 首字下沉与引词

段落样式`lede`给所在组的第一段加一个三行深的GFS Didot首字，`leadIn`把后面四个词排成大写：ΜΕ ΜΙΑ ΓΙΟΡΤΗ ΠΟΥ。它们同样去掉重音（[首字下沉](https://postext.dev/zh/docs/configuration-text.md)）。这条新闻以Μ开头；如果以带重音的大写字母（Έ、Ό）开头，要在页面上看看首字，因为希腊图书的首字母不带重音。

### 4 · 报头

```js
// script.js, 行 65–81
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
  content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 6)
    : at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(52) } }));
const caps = { letterSpacing: pt(1.4), textTransform: 'uppercase' };
const nameplate = { enabled: true, minHeight: mm(38), slot: { elements: [
  text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(60), lineHeight: 1.1,
    color: col('aegean'), align: 'center', ...caps, letterSpacing: pt(4) },
  { ...at('container', 'top', 0, 1), size: { width: 'fill' } }),
  ...ear('start', 'left', [['k', '{attr.issue}', sans(8, 700, 'aegean', caps)],
    ['d', '{publishDate}', sans(9, 400)]]),
  ...ear('end', 'right', [['k', '{attr.city}', sans(8, 700, 'aegean', caps)],
    ['p', '{attr.price}', sans(9, 400)]]),
  { kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 32), size: { width: 'fill' } } },
  { kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
    placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };
```

报名在frontmatter里写作«Ο Φάρος»，排成加字距的Didot大写：ΦΑΡΟΣ。报耳读取标题属性`issue`、`city`、`price`和frontmatter里的`publishDate`。

## 完整食谱

一个文件，由食谱文件夹合成，示例文本和排版食谱的公共工具包都已内联；它自己排出页面。要运行它，把它放进空白页面的`<script type="module">`，或粘贴到新建CodePen的JS面板里（设为模块）。它从esm.sh导入postext，不需要安装或构建。

- 食谱文件夹: https://github.com/drnachio/postext/tree/main/cookbook/greek-daily-front-page

### script.js

```js
// ═══ Postext Cookbook · Nº 204 · A Greek daily's front page in three columns ═══════════
// https://postext.dev/en/cookbook/greek-daily-front-page
// Code: MIT · Text: original Greek news copy (CC BY 4.0) · Map: drawn in code (CC BY 4.0)
// Fonts: GFS Didot, Fira Sans Condensed, Noto Serif (SIL OFL 1.1) · Needs postext ≥ 1.99.1
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the imprint's last line; the paper is Greek
const RECIPE = 'greek-daily-front-page';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, black ink and the paper's Aegean blue
const palette = {
  ink: '#141518', // text and the heavy rules
  aegean: '#1d4f91', // the accent: the nameplate, kickers, the ferry lines
  foam: '#e4e9f0', // the In brief strip, the map's sea
  land: '#efe9dc', // the map's land
  rule: '#9a9890', // hairlines: the column rules, the imprint's rule
  muted: '#5a5852', // bylines, captions' notes, the imprint
  paper: '#f9f7f1', // newsprint
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [NAME, HEAD, TEXT] = ['GFS Didot', 'Fira Sans Condensed', 'Noto Serif']; // all with Greek
const TRIM = { width: 246, height: 328 }; // mm: a 3 : 4 compact
const SIDE = 12; // mm: newspaper margins, narrow and not mirrored
const LEAD = 13.5; // pt: the body leading, 1.5 × a 9 pt Noto Serif
const sans = (size, weight, colour = 'ink', extra = {}) => ({ fontFamily: HEAD, fontSize: pt(size),
  fontWeight: weight, color: col(colour), ...extra });
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
  ...look, placement });

// #region answer: Greek in three columns, the headline in capitals, the story under a drop cap
// locale 'el' hyphenates the narrow columns with the monotonic patterns and makes every
// capital setting drop the tonos: the lead headline is written «Ο φάρος του Αγίου Νικολάου
// ανάβει ξανά» in the Markdown and printed ΑΝΑΒΕΙ ΞΑΝΑ, never ΑΝΆΒΕΙ.
const LOCALE = 'el';
const layout = { layoutType: 'multiple', columnCount: 3, gutterWidth: mm(5),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
const headline = { id: 'lead', fontSize: pt(30), lineHeight: pt(34), fontWeight: 800,
  textTransform: 'uppercase', letterSpacing: em(0.01), marginBottom: pt(6) };
// :::paragraphs{style="lede"} opens the story: a drop cap three lines deep and its first
// four words in capitals, which drop the tonos the same way (ΜΕ ΜΙΑ ΓΙΟΡΤΗ).
const lede = { id: 'lede', firstLineIndent: pt(0),
  dropCap: { lines: 3, fontFamily: NAME, color: col('aegean'), gap: mm(1.2),
    leadIn: { words: 4, uppercase: true } } };
// #endregion

// #region banner: headlines over the columns are page-span boxes without a frame
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...sans(9, 700, 'aegean', { letterSpacing: pt(1.6),
    textTransform: 'uppercase' }), gap: mm(1.5) }, // the kicker, from the fence's title
  marginTop: pt(LEAD), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(17), textAlign: 'left',
    firstLineIndent: pt(0) } };
// #endregion

// #region nameplate: the paper's name in Didot between two ears
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
  content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 6)
    : at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(52) } }));
const caps = { letterSpacing: pt(1.4), textTransform: 'uppercase' };
const nameplate = { enabled: true, minHeight: mm(38), slot: { elements: [
  text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(60), lineHeight: 1.1,
    color: col('aegean'), align: 'center', ...caps, letterSpacing: pt(4) },
  { ...at('container', 'top', 0, 1), size: { width: 'fill' } }),
  ...ear('start', 'left', [['k', '{attr.issue}', sans(8, 700, 'aegean', caps)],
    ['d', '{publishDate}', sans(9, 400)]]),
  ...ear('end', 'right', [['k', '{attr.city}', sans(8, 700, 'aegean', caps)],
    ['p', '{attr.price}', sans(9, 400)]]),
  { kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 32), size: { width: 'fill' } } },
  { kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
    placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };
// #endregion

const config = () => ({
  locale: LOCALE, // written out, never LANG: the paper is Greek in every edition
  colorPalette, resourceTypes, layout,
  page: { width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150,
    backgroundColor: col('paper'), margins: { top: mm(12), bottom: mm(14), left: mm(SIDE),
      right: mm(SIDE) } },
  bodyText: { fontFamily: TEXT, fontSize: pt(9), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: em(1), indentAfterHeading: false,
    // Columns of 69 mm hold about seven Greek words: wide spaces are let go first, then a
    // little tracking.
    hyphenateAcrossColumns: false, minWordSpacing: 0.8, maxWordSpacing: 1.6,
    maxJustifyTracking: 14 },
  headings: { fontFamily: HEAD, fontWeight: 700, color: col('ink'), marginBottom: pt(0),
    levels: [
      { level: 1, span: 'page' },
      { level: 2, fontSize: pt(16), lineHeight: pt(20), marginTop: pt(LEAD / 2) },
      { level: 3, fontSize: pt(10.5), lineHeight: pt(LEAD), marginTop: pt(LEAD / 2) },
    ] },
  headingStyles: [
    { id: 'front', advancedDesign: nameplate, header: { elements: [] } },
    headline,
    { id: 'wide', fontSize: pt(20), lineHeight: pt(24), marginBottom: pt(2) },
  ],
  calloutStyles: [banner,
    { ...banner, id: 'briefs', background: col('foam'), backgroundEnabled: true,
      padding: { top: mm(3), right: mm(4), bottom: mm(3.5), left: mm(4) }, columnGap: mm(6),
      marginTop: pt(LEAD), titleStyle: { ...sans(10, 800, 'aegean', caps), gap: mm(2) },
      body: { fontFamily: TEXT, fontSize: pt(8.5), lineHeight: pt(12.5), textAlign: 'left',
        firstLineIndent: pt(0) } }],
  paragraphStyles: [
    { id: 'byline', ...sans(8.5, 400, 'muted'), firstLineIndent: pt(0), textAlign: 'left' },
    lede,
    { id: 'imprint', ...sans(7.5, 400, 'muted'), lineHeight: pt(10), firstLineIndent: pt(0),
      textAlign: 'left', marginTop: pt(LEAD / 2), hyphenation: { enabled: false } },
  ],
  tableStyle: { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
    headerBackground: col('aegean'), headerColor: col('paper'), headerFontFamily: HEAD,
    headerFontSize: pt(8.5), bodyFontFamily: HEAD, bodyFontSize: pt(9), bodyColor: col('ink'),
    cellPadding: mm(1.2) },
  captionStyle: { ...sans(8.5, 400), gap: mm(1.5),
    note: { fontSize: pt(7.5), color: col('muted') } },
  header: { elements: [] }, footer: { elements: [] },
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
// The front page (content.text.<lang>.md), then the imprint in the edition's language.
const markdown = [String.raw`---
title: "Ο Φάρος"
publishDate: "Πέμπτη 1 Οκτωβρίου 2026"
---

# Ο Φάρος {style="front" issue="Έτος 38 · Αρ. φύλλου 11.204" city="Άγιος Νικόλαος" price="Τιμή: 1,50 €"}

:::callout{type="banner" title="Πόλη"}
## Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια {style="lead"}

**Πάνω από τρεις χιλιάδες κάτοικοι ανέβηκαν χθες το βράδυ στο ακρωτήρι για να δουν το πρώτο φως. Ο δήμος θα ανοίγει τον πύργο στους επισκέπτες κάθε Σαββατοκύριακο.**
:::

:::paragraphs{style="byline"}
Γράφει η **Ελένη Μαυρίδη**
:::

:::paragraphs{style="lede"}
Με μια γιορτή που κράτησε ως τα μεσάνυχτα, η πόλη είδε χθες ξανά το φως του φάρου της να γυρίζει πάνω από τον κόλπο. Στις οχτώ και δέκα ακριβώς, ο τελευταίος φαροφύλακας της πόλης, ο ογδοντάχρονος Μιχάλης Σταυρόπουλος, γύρισε τον διακόπτη και ο φακός άρχισε να στρίβει, ενώ οι καμπάνες του Αγίου Νικολάου χτυπούσαν και τα καΐκια στο λιμάνι σφύριζαν.
:::

Ο φάρος χτίστηκε το 1889 και έσβησε το 1986, όταν η ναυσιπλοΐα πέρασε στα ηλεκτρονικά συστήματα και ο πύργος έμεινε χωρίς φύλακα. Οι αρμύρες έφαγαν τα σίδερα της σκάλας, ο φακός κατέβηκε σε μια αποθήκη του λιμεναρχείου και τα παράθυρα σφραγίστηκαν με τσιμεντόλιθους.

Η αποκατάσταση κράτησε τρία χρόνια και κόστισε 1,2 εκατομμύρια ευρώ, από τα οποία τα μισά ήρθαν από ευρωπαϊκό πρόγραμμα. Οι μάστορες ξήλωσαν και ξανάστησαν τη σκάλα σκαλί σκαλί, με λάμες σφυρήλατου σιδήρου στα σχέδια του 1889, και ένας Γάλλος τεχνίτης καθάρισε και ξαναζύγισε τον παλιό φακό Fresnel.

### Ο φύλακας και τα κλειδιά

«Ήρθα εδώ το 1962, είκοσι δύο χρονών», είπε ο κ. Σταυρόπουλος στους δημοσιογράφους, κρατώντας τα παλιά κλειδιά του πύργου. «Κάθε βράδυ ανέβαινα εκατόν δεκαέξι σκαλιά. Όταν τον έσβησαν, νόμιζα πως δεν θα τον ξανάβλεπα αναμμένο». Ο δήμαρχος τού παρέδωσε τιμητικά ένα αντίγραφό τους.

::resource{id="kolpos"}

Το φως δεν θα οδηγεί πια τα πλοία, που ταξιδεύουν με δορυφορικά συστήματα, όμως το λιμεναρχείο το κατέγραψε ξανά στους χάρτες ως βοηθητικό σήμα. Θα ανάβει κάθε βράδυ με το σούρουπο και θα σβήνει την αυγή, με δύο αναλαμπές κάθε δεκαπέντε δευτερόλεπτα, όπως παλιά.

### Επισκέψεις στον πύργο

Από το ερχόμενο Σάββατο ο πύργος θα δέχεται επισκέπτες κάθε Σαββατοκύριακο, από τις δέκα το πρωί ως τη δύση του ήλιου. Η είσοδος θα κοστίζει τρία ευρώ, ενώ για τους μαθητές και τους κατοίκους του δήμου θα είναι δωρεάν. Στο ισόγειο, στο παλιό σπίτι του φύλακα, ετοιμάζεται μικρό μουσείο με τα ημερολόγια της υπηρεσίας και φωτογραφίες από το αρχείο του λιμεναρχείου.

:::callout{type="banner" title="Λιμάνι"}
## Δύο νέα δρομολόγια για τη Μικρή Ροδιά {style="wide"}
:::

:::paragraphs{style="byline"}
Γράφει ο **Νίκος Αλεξίου**
:::

Από τη Δευτέρα το καραβάκι για τη Μικρή Ροδιά θα κάνει δύο δρομολόγια την ημέρα αντί για ένα, ως το τέλος Οκτωβρίου. Η απόφαση πάρθηκε ύστερα από αίτημα του συλλόγου του νησιού, γιατί τα παιδιά που φοιτούν στο λύκειο της πόλης έμεναν ως το απόγευμα στην αποβάθρα. Το εισιτήριο μένει στα τέσσερα ευρώ.

::resource{id="dromologia"}

:::callout{type="briefs" span="page" placement="bottom" title="Σύντομα"}
:::columns{count=3 breaks="2,3"}
**Η βιβλιοθήκη ανοίγει τα βράδια.** Η δημοτική βιβλιοθήκη θα μένει ανοιχτή ως τις δέκα το βράδυ τις καθημερινές, όσο κρατούν οι εξετάσεις.

**Αρχίζει η σαρδέλα.** Η περίοδος της σαρδέλας ανοίγει στις 15 Οκτωβρίου, μια εβδομάδα νωρίτερα από κάθε χρόνο.

**Κλειστή η παραλιακή.** Η παραλιακή κλείνει την Κυριακή από τις επτά ως τις έντεκα το πρωί, για τον αγώνα δρόμου της πόλης.
:::
:::
`, String.raw`:::paragraphs{style="imprint"}
An imaginary daily from an imaginary town, written in Greek for the Postext Cookbook. Set in GFS Didot, Fira Sans Condensed and Noto Serif (SIL OFL). Text and map are original and licensed CC BY 4.0.
:::
`].join('\n\n');

// #region art: the bay, the lighthouse on its cape and the two ferry lines
function baySvg() { // 69 × 52 mm, 1 unit = 1 mm: one column wide
  const [W, H] = [69, 52];
  const land = 'M0 0H69V14C60 16 55 12 50 15S44 24 38 22S30 14 24 17S18 30 12 28S4 22 0 24Z';
  const island = 'M44 40C47 37 53 37 56 40S54 46 50 46S41 43 44 40Z';
  const line = (d) => `<path d="${d}" fill="none" stroke="${palette.aegean}" stroke-width="0.8" `
    + 'stroke-dasharray="2 1.4"/>';
  const beam = `<path d="M12 28L-4 52H22Z" fill="${palette.aegean}" fill-opacity="0.12"/>`;
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${W * 10}" height="${H * 10}" `
    + `viewBox="0 0 ${W} ${H}"><rect width="${W}" height="${H}" fill="${palette.foam}"/>${beam}`
    + `<path d="${land}" fill="${palette.land}" stroke="${palette.rule}" stroke-width="0.3"/>`
    + `<path d="${island}" fill="${palette.land}" stroke="${palette.rule}" stroke-width="0.3"/>`
    + line('M38 22C40 30 44 34 48 38') + line('M38 22C34 34 30 44 28 52')
    + `<circle cx="38" cy="21.5" r="1.4" fill="${palette.ink}"/>`
    + `<circle cx="12" cy="28" r="1.8" fill="${palette.paper}" stroke="${palette.ink}" `
    + 'stroke-width="0.7"/></svg>';
}
// #endregion
// Newspapers do not number their pictures: a type with no caption label and no counter.
const unnumbered = (id, name, captionStyle) => ({ id, name, shortLabel: name, captionPrefix: '',
  numberingTemplate: '', resetOn: 'never', counterFormat: 'decimal', captionStyle });
const resourceTypes = [unnumbered('picture', 'Χάρτης'),
  unnumbered('panel', 'Πίνακας', { position: 'above' })]; // tables titled above
// The day's sailings from the harbour, one row a ship.
const SAILINGS = [['07:30', 'Πειραιάς', 'Αγία Θεοδώρα'], ['09:15', 'Νησί Ροδιάς', 'Μικρή Ροδιά'],
  ['13:40', 'Νησί Ροδιάς', 'Μικρή Ροδιά'], ['17:00', 'Πειραιάς', 'Αγία Θεοδώρα']];
const cell = (content, extra = {}) => ({ content, ...extra });
const sailings = { headerRowCount: 1, rows: [
  ['Ώρα', 'Προορισμός', 'Πλοίο'].map((head) => cell(head, { isHeader: true })),
  ...SAILINGS.map((row) => row.map((value) => cell(value))),
] };
const resources = [
  { id: 'kolpos', typeId: 'picture', kind: 'svg', createdAt: 0, updatedAt: 0,
    svg: { fileId: 'bay.svg', width: 690, height: 520 }, placement: { position: 'here' },
    caption: '**Ο κόλπος του Αγίου Νικολάου.** Ο φάρος στο ακρωτήρι και οι δύο γραμμές των '
      + 'πλοίων από το λιμάνι.',
    altText: 'Χάρτης: ακτή στο πάνω μέρος, ένα ακρωτήρι αριστερά με τον φάρο, το λιμάνι στη '
      + 'μέση και δύο διακεκομμένες γραμμές πλοίων, η μία προς ένα νησάκι και η άλλη προς '
      + 'το ανοιχτό πέλαγος.' },
  { id: 'dromologia', typeId: 'panel', kind: 'table', createdAt: 0, updatedAt: 0,
    table: { model: sailings }, placement: { position: 'here' },
    caption: '**Δρομολόγια** από το λιμάνι, Πέμπτη 1 Οκτωβρίου' },
];

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { // every face the page uses, loaded before the build
  'GFS Didot': ['400'], // NAME: the nameplate and the drop cap
  'Fira Sans Condensed': ['400', '700', '800'], // HEAD: headlines, kickers, bylines, table
  'Noto Serif': ['400', '700'], // TEXT: the stories and the standfirsts; bold emphasis
};

// ─── 4 · Build & show ───────────────────────────────────────────────────────
await loadSvg('bay.svg', baySvg());
const doc = await buildDocumentWithFonts({ markdown, resources }, config(), kitFonts(FONTS));
showPages(doc, { title: 'Ο Φάρος' });
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes }),
  `${RECIPE}.pdf`);

// ─── 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 · pdf v3 ── the same in every recipe that exports a PDF
/** The Fontsource files the screen used, as TrueType, with their range and
 *  place: the nearest weight the family ships in that style, upright with no italic;
 *  latin, then what its letters need (kitSubsetsFor). */
async function fontsourceProvider(family, weight, style, request) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  const s = style === 'italic' && meta && !meta.styles.includes('italic') ? 'normal' : style;
  const shipped = meta ? await fontsourceWeights(family, s) : [];
  const weights = shipped.length ? shipped : [400, 700];
  const w = weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a));
  const text = String.fromCodePoint(...(request?.codePoints ?? []));
  const files = await Promise.all(['latin', ...kitSubsetsFor(text, meta)].map(async (subset, order) => {
    const res = await fetch(`${await fontsourceAt(id)}files/${id}-${subset}-${w}-${s}.woff2`);
    if (!res.ok) throw new Error(`Fontsource has no ${family} ${w} ${s} ${subset}`);
    return Object.assign(await decompressWoff2(new Uint8Array(await res.arrayBuffer())),
      { unicodeRange: kitRanges()[subset], order });
  }));
  return files.length === 1 ? files[0] : files;
}

/** A "Build the PDF" button; then "Open the PDF" (a new tab: CodePen's frame
 *  shows no PDFs) and a download link. */
function offerPdf(makePdf, filename) {
  viewer();
  const button = Object.assign(document.createElement('button'), { type: 'button', textContent: 'Build the PDF' });
  button.dataset.postextPdf = filename;
  button.addEventListener('click', async () => {
    button.disabled = true;
    button.textContent = 'Building the PDF…';
    try {
      const bytes = await makePdf();
      const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
      const size = `${Math.max(1, Math.round(bytes.length / 1024))} KB`;
      button.replaceWith(
        Object.assign(document.createElement('a'), { href: url, target: '_blank', rel: 'noopener', textContent: 'Open the PDF ↗' }),
        Object.assign(document.createElement('a'), { href: url, download: filename, textContent: `Download ${filename} · ${size}` }));
    } catch (error) {
      button.disabled = false;
      button.textContent = 'Build the PDF';
      kitFail(error);
    }
  });
  document.getElementById('pt-actions').append(button);
}

// ─── Kit · images v3 ── recipes with pictures · postext.dev/cookbook
/** Registers a photo or PNG for the canvas and keeps its bytes for the PDF.
 *  fetch → ImageBitmap never taints the canvas (a plain cross-origin <img> would). */
async function loadImage(fileId, url) {
  const res = await fetch(url);
  if (!res.ok) throw new Error(`Image not found (${res.status}): ${url}`);
  const bytes = new Uint8Array(await res.arrayBuffer());
  registerResourceImage(fileId, await createImageBitmap(new Blob([bytes])));
  (loadImage.bytes ??= new Map()).set(fileId, bytes);
}

/** Registers SVG markup as a vector image, its fonts inside (inlineSvgFonts, ≥ 1.25).
 *  `options` go to registerResourceImage: { singleInk: true } tints it on the canvas. */
async function loadSvg(fileId, svg, options) {
  if (typeof inlineSvgFonts === 'function') svg = await inlineSvgFonts(svg, svgFaces);
  const img = new Image();
  img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
  await img.decode();
  registerResourceImage(fileId, img, options);
  (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg));
}

/** A face's Fontsource files: nearest weight; latin + what the SVG sets. */
async function svgFaces(family, weight, style, { codePoints = [] } = {}) {
  const [id, m] = [fontsourceId(family), await fontsourceMeta(family)];
  const w = m?.weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)) ?? weight;
  const s = m?.styles.includes(style) === false ? 'normal' : style;
  return Promise.all(['latin', ...kitSubsetsFor(String.fromCodePoint(...codePoints), m)].map(async (x) => new Uint8Array(
    await (await fetch(`${await fontsourceAt(id)}files/${id}-${x}-${w}-${s}.woff2`)).arrayBuffer())));
}

/** renderToPdf({ resourceBytes: imageBytes }) */
function imageBytes(fileId) { return loadImage.bytes?.get(fileId); }

/** renderToHtml({ resourceImageUrl: imageUrl }) */
function imageUrl(fileId) {
  const bytes = imageBytes(fileId);
  if (!bytes) return undefined;
  imageUrl.urls ??= new Map();
  if (!imageUrl.urls.has(fileId)) {
    const type = /\.svg$/i.test(fileId) ? 'image/svg+xml' : /\.png$/i.test(fileId) ? 'image/png' : 'image/jpeg';
    imageUrl.urls.set(fileId, URL.createObjectURL(new Blob([bytes], { type })));
  }
  return imageUrl.urls.get(fileId);
}

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

## 常见问题

- 框里要求的首字下沉不会排出：新闻的第一段必须在正文流里、框之后，不能在框内。
- 简讯是`placement="bottom"`的框：页面多出一行，整条简讯就移到下一页。删减文字直到放得下。
- 报耳宽52 mm。期号一行更长就会转行，第二行跑到报名第一个字母下面；按报名留下的空间来量报耳。

## 致谢

- 食谱: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- 字体: GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)
- 代码: MIT · 示例内容: CC-BY-4.0

## 相关食谱

- [No. 108 · 双栏阿拉伯文报纸版面](https://postext.dev/zh/cookbook/arabic-newspaper-two-columns.md): 阿拉伯文日报的两个版面：locale 'ar'让右边一栏排在最前，通栏标题横跨两栏，简讯栏里的三栏也从右向左排。 · 难度 2 (中级) · 报纸与通讯
- [No. 201 · 按单调正字法断词的希腊语小说](https://postext.dev/zh/cookbook/monotonic-greek-novel.md): 把Theotokis《Η τιμή και το χρήμα》第一章排成13.5 × 20.5 cm的书：单调希腊语断词、«»引号、不带重音的大写书眉。 · 难度 2 (中级) · 小说、戏剧与文学散文
- [No. 203 · 希腊语数学课本的一章](https://postext.dev/zh/cookbook/greek-maths-textbook.md): 给希腊学生讲勾股定理的三页：3.1到3.3节用不带tonos的大写，图表标签为Εικόνα和Πίνακας，公式用MathJax。 · 难度 3 (高级) · 教科书
