انتقل إلى المحتوى الرئيسي
الوصفة رقم 35

دليل الوصفات · الفصل 8 · الجداول

تقويم بستاني: شبكة تقويم ومخطط مستعرض

مخطط زراعة لثمانية وثلاثين محصولًا مُنضَّد بالعرض على صفحتين خاصتين به، وتقويم محسوب من التواريخ ومصفوفة رفقة، خلاياها ممتلئة من لوحة الألوان.

في هذه الصفحة
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 210 × 280 مم
  • عمودان, فاصل 7 مم بين الأعمدة
  • Piazzolla 9.8/14
  • Commissioner
  • Gilda Display
  • 4 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 80 ms
  • أسطر الشيفرة: 251

باختصار

صفحات شهر مارس من تقويم بستاني، فيها تقويم شهري ومخططات ملونة. تبيّن كيف تبني جداول من البيانات، وكيف تدير على جانبه مخططًا أعرض من الصفحة.

ما الذي ستنضده

صفحات شهر مارس من تقويم بستاني مكتوب بالإيطالية. تُفتتح الصفحة 27 بلوحة مائية لشتلات في تربة داكنة تحت سماء شاحبة، واسم الشهر بحجم 84 نقطة، ومثل ريفي. وتحت عمودين من النص يأتي تقويم الشهر، الذي يحسبه المثال من التواريخ: أيام الأحد بالأحمر على عمود كريمي، وأحد الفصح واثنينه على وردي، وأرباع القمر الأربعة مرسومة إلى جانب أيامها. وتسرد الصفحة 28 أعمال الشهر في إطار من عمودين، وتلوّن مصفوفة لرفقة النباتات عشرة في عشرة بالأخضر أو الوردي أو الكريمي، مع رسم لكل محصول على القطر. ومواعيد البذر للسنة كلها، 38 محصولًا بأنصاف الأشهر، أعرض من الصفحة، فيدور المخطط ربع دورة على الصفحتين 29 و30 ويكرر رأسه على الثانية.

تجيب هذه الوصفة عن

  • كيف أنضد جدولًا عريضًا بالاتجاه الأفقي في صفحة مستقلة؟
  • كيف أصنع جدولًا فيه صفوف رأس، وخلايا مدمجة، وعروض أعمدة، ومحاذاة لكل خلية؟
  • كيف أنسّق عدة جداول تنسيقات مختلفة (تعبئة، خلايا مخططة بالتناوب، أطر مستديرة) في مستند واحد؟
  • كيف أضع صورًا أو أيقونات داخل خلايا الجدول؟
  • كيف أضيف عيّنات لونية دليلية إلى النص أو التعليقات أو ملاحظات الجداول؟

الجواب المختصر

script.js · الأسطر 31–67في الشيفرة الكاملة
// The chart's `placement` (#region resources): a quarter turn makes it a page-span float on
// pages of its own, flush to the spine; rows past the page's width go on under a repeated head.
const chartPlacement = { rotate: 'ccw' }; // a float: 'here' ignores the turn
const MONTHS = ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'];
const SEASONS = [['INVERNO', 2], ['PRIMAVERA', 3], ['ESTATE', 3], ['AUTUNNO', 3], ['INVERNO', 1]];
const STATES = { S: 'ochre', C: 'green', T: 'brown' }; // seedbed, sown outdoors, planted out
const fortnight = (key) => MONTHS.indexOf(key.slice(0, 3)) * 2 + Number(key[3]); // 'mar2' → 6
function sowingChart(data) { // 'Pomodoro: S feb2–mar2, T apr2–mag2'; a bare line is a family
  const row = (first, isHeader = false) => [first, ...Array(24).fill('')]
    .map((content) => ({ content, isHeader }));
  let m = { headerRowCount: 2, columnWidths: [30, ...Array(24).fill(8.5)], // mm, as weights
    rows: [row('', true), row('', true)] };
  for (const line of data.trim().split('\n')) {
    const [name, plan] = line.split(': ');
    const r = m.rows.push(row(plan ? name : chip(name.toUpperCase(), 'famiglia'))) - 1;
    if (!plan) { m = mergeCells(m, span(r, 0, r, 24)); continue; } // a family heads its crops
    for (let f = 1; f <= 24; f++) { // every other month tinted, so a column reads down the page
      if ((f - 1) % 4 < 2) m = setCellBackground(m, at(r, f), col('cream'));
    }
    for (const step of plan.split(', ')) { // 'S feb2–mar2': one state over a run of fortnights
      const [state, range] = step.split(' ');
      const [from, to = from] = range.split('–').map(fortnight);
      for (let f = from; f <= to; f++) m = setCellBackground(m, at(r, f), col(STATES[state]));
    }
  }
  // Merged heads: 'Coltura' down both rows, each season over its months, each month over its
  // two fortnights. mergeCells marks the covered cells hiddenBy (gotcha: merged-cells-hiddenby).
  const merge = (r0, c0, r1, c1, content) => { // the head's text goes in its first cell
    m = mergeCells(setCellContent(m, at(r0, c0), content), span(r0, c0, r1, c1));
  };
  merge(0, 0, 1, 0, 'Coltura');
  let c = 1;
  for (const [name, n] of SEASONS) { merge(0, c, 0, c + 2 * n - 1, name); c += 2 * n; }
  MONTHS.forEach((month, i) => merge(1, 2 * i + 1, 1, 2 * i + 2, month.toUpperCase()));
  for (const r of [0, 1]) for (let f = 1; f <= 24; f++) m = setAlignment(m, at(r, f), 'center');
  return setCellBackground(m, at(1, fortnight('mar1')), col('red')); // this month's head
}

المكونات

الخطوط
Piazzolla, Gilda Display, Commissioner (SIL OFL 1.1)
الأصول
  • campo-1680.jpg
  • The opener’s field of seedlings in March, a watercolour (Generated With Diffusion Models, أصلي)
  • The moon’s quarters and the ten crops, drawn in code in the page’s palette (Ignacio Ferro, CC BY 4.0)

طريقة التحضير

#1 · أدر المخطط ودعه يستمر

الشيفرة هي الجواب المختصر أعلاه. يجعل rotate: 'ccw' الجدول عنصرًا عائمًا بعرض الصفحة على صفحات خاصة به (الموضع)، ورأسه نحو الحافة اليسرى للصفحة، ويلاصق الكعب على الصفحة الفردية والزوجية كلتيهما. ويُخرَج على امتداد ارتفاع منطقة النص، 227 مم من أصل 237: أسطر الشبكة الكاملة بارتفاع 14 نقطة التي تتسع لها، وعددها 47، ناقصًا سطرًا للفراغ حول العنصر العائم. وتتراكم صفوفه عبر العرض البالغ 176 مم، وحين تتجاوزه يُقطع الجدول بين صفّين ويستمر في الصفحة التالية تحت صفّي رأسه وتعليقه، الذي ينتهي بـ(segue) (الجداول الأطول من الصفحة). وحده العنصر العائم يستطيع أن يدور: مع position: 'here' يُتجاهل الدوران، وينقسم الجدول بلا دوران، بين الصفوف، حيث ينتهي عموده. ودُمجت خلايا الرأس بثلاث طرق: Coltura على امتداد صفّي الرأس، وكل فصل فوق أشهره، وكل شهر فوق نصفيه.

#2 · تقويم محسوب من التواريخ

script.js · الأسطر 71–110في الشيفرة الكاملة
const [YEAR, MONTH, DAY] = [2027, 3, 24 * 60 * 60 * 1000]; // DAY in ms
const epochDay = (m, d) => Date.UTC(YEAR, m - 1, d) / DAY; // 1 January 1970 was a Thursday
const weekday = (d) => (epochDay(MONTH, d) + 3) % 7; // 0 is Monday: Italian weeks start there
function easter(y) { // the Gregorian computus (Meeus): [month, day]
  const a = y % 19, b = Math.floor(y / 100), c = y % 100, d = Math.floor(b / 4);
  const g = Math.floor((8 * b + 13) / 25), h = (19 * a + b - d - g + 15) % 30;
  const i = Math.floor(c / 4), k = c % 4, l = (32 + 2 * (b % 4) + 2 * i - h - k) % 7;
  const n = h + l - 7 * Math.floor((a + 11 * h + 22 * l) / 451) + 114;
  return [Math.floor(n / 31), (n % 31) + 1];
}
// The moon's age: mean synodic months since the new moon of 6 January 2000 at 18.14 UT.
const [SYNODIC, NEW_MOON] = [29.530588853, Date.UTC(2000, 0, 6, 18, 14) / DAY];
const quarter = (day) => Math.floor((((day - NEW_MOON) % SYNODIC) / SYNODIC) * 4); // 0–3
const PHASES = ['luna-nuova', 'primo-quarto', 'luna-piena', 'ultimo-quarto'];
const JOINER = '\u2060'; // a word joiner: the second line of a day without a note
const DAYS = ['LUNEDÌ', 'MARTEDÌ', 'MERCOLEDÌ', 'GIOVEDÌ', 'VENERDÌ', 'SABATO', 'DOMENICA'];
function calendarTable() { // the grid, and the quarters it draws, listed for the caption
  const e = epochDay(...easter(YEAR)) - epochDay(MONTH, 0); // Easter as a day of MONTH: 28 in 2027
  const feasts = { [e - 7]: 'Le Palme', [e]: 'Pasqua', [e + 1]: 'Pasquetta' };
  const notes = { 19: 'S. Giuseppe', 20: 'Equinozio' }; // March 2027's, typed by hand
  const first = weekday(1), days = epochDay(MONTH + 1, 1) - epochDay(MONTH, 1), moons = [];
  const week = (names, isHeader) => names.flatMap((content) => [content, '']) // a day: moon, date
    .map((content) => ({ content, isHeader }));
  let m = { headerRowCount: 1, columnWidths: Array(7).fill([7, 18]).flat(), rows: [week(DAYS, true),
    ...Array.from({ length: Math.ceil((first + days) / 7) }, () => week(Array(7).fill('')))] };
  for (let d = 1; d <= days; d++) {
    const r = 1 + Math.floor((first + d - 1) / 7), c = 2 * weekday(d), sunday = c === 12;
    // Sundays and feasts print in red. Every day has a second line, so all weeks are as tall.
    const note = feasts[d] ? chip(feasts[d], 'festa') : notes[d] ? chip(notes[d], 'nota') : JOINER;
    m = setCellContent(m, at(r, c + 1), `${sunday || feasts[d] ? chip(d, 'rosso') : d}\n${note}`);
    const fill = d === e || d === e + 1 ? 'blush' : sunday ? 'cream' : null;
    if (fill) for (const k of [c, c + 1]) m = setCellBackground(m, at(r, k), col(fill));
    const midnight = epochDay(MONTH, d) - 1 / 24, q = quarter(midnight + 1); // 00.00 CET
    if (q === quarter(midnight)) continue;
    m = setCellImage(m, at(r, c), { resourceId: PHASES[q] }); // a quarter begins today
    moons.push(`${PHASES[q].replace('-', ' ')} ${[1, 8, 11].includes(d) ? 'l’' : 'il '}${d}`);
  }
  for (let i = 0; i < 7; i++) m = mergeCells(m, span(0, 2 * i, 0, 2 * i + 1)); // one head a day
  return { model: setCellBackground(m, at(0, 12), col('red')), moons: moons.join(', ') };
}

أرقام الأيام المستخرجة من Date.UTC تحدّد لكل تاريخ يومه من الأسبوع، وتبدأ الشبكة يوم الاثنين 1 مارس وتمتد خمسة أسابيع. يأتي عيد الفصح من حساب الفصح (computus)، وأرباع القمر من متوسط الشهر الاقتراني. وبهذا الحساب قد يقع الربع قبل موعده بيوم أو بعده، كما يذكر التعليق. والحلقة التي ترسم كل قمر تكتب تاريخه في التعليق أيضًا. صورة الخلية تقع دائمًا فوق نصها، ولهذا يأخذ كل يوم عمودين، عمود القمر وعمود التاريخ: فلو وُضع القمر في خلية التاريخ نفسها لدفع التاريخ إلى الأسفل في أربعة أيام فقط. أيام الأحد والأعياد حمراء بنمط شارة لا يغيّر سوى اللون، والملاحظات شارات بنصف الحجم. واليوم الذي لا ملاحظة له يأخذ رابط كلمات (U+2060) سطرًا ثانيًا، فيبقى للأسابيع الخمسة الارتفاع نفسه.

#3 · لوّن المصفوفة من رموز ملصوقة

script.js · الأسطر 114–130في الشيفرة الكاملة
const FILLS = { '+': 'leaf', '−': 'blush', '': 'cream' }; // good, bad, no known effect
function companionTable(tsv) {
  let m = { ...parseTSV(tsv, { headerRows: 1 }), columnWidths: [26, ...Array(10).fill(15)] };
  for (let r = 1; r < m.rows.length; r++) {
    m = setAlignment(m, at(r, 0), 'left', 'middle');
    for (let c = 1; c < m.rows[r].length; c++) {
      const symbol = m.rows[r][c].content; // + and − stay printed, for greyscale copies
      m = setCellContent(m, at(r, c), symbol && symbol !== '=' ? chip(symbol, 'segno') : '');
      m = symbol === '=' // the diagonal pairs a crop with itself: its picture instead
        ? setCellImage(m, at(r, c), { resourceId: `veg-${r}`, width: 0.62 })
        : setCellBackground(m, at(r, c), col(FILLS[symbol]));
      m = setAlignment(m, at(r, c), 'center', 'middle');
    }
  }
  for (let c = 1; c <= 10; c++) m = setAlignment(m, at(0, c), 'center');
  return m;
}

تُكتب الأزواج بصيغة TSV، رمز واحد في كل خلية. وتجعل parseTSV(tsv, { headerRows: 1 }) صف أسماء المحاصيل رأسًا. أوزان columnWidths مليمترات من عرض السطر البالغ 176 مم: 26 للأسماء و15 لكل محصول. يشير كل رمز إلى مدخل في لوحة الألوان، تضعه setCellBackground تعبئةً للخلية؛ وتُطبع + و− أيضًا، في شارة بحجم 1.4 em، فتبقى المصفوفة مقروءة في نسخة رمادية. القطر يقرن كل محصول بنفسه، وهناك تضع setCellImage رسم المحصول، بعرض 62 % من العرض الداخلي للخلية.

#4 · اصنع مفتاح الألوان من عيّنات

script.js · الأسطر 396–420في الشيفرة الكاملة
const resourceTypes = [ // the almanac's own two: tables numbered through, a bare calendar
  { id: 'table', name: 'Tabella', shortLabel: 'Tab.', captionPrefix: 'Tabella',
    captionStyle: { position: 'above' } },
  { id: 'calendar', name: 'Calendario', shortLabel: 'Cal.', captionPrefix: '' }, // no label
].map((t) => ({ numberingTemplate: '{n}', resetOn: 'never', counterFormat: 'decimal', ...t }));
const table = (id, typeId, caption, model, styleId, extra) => ({ id, typeId, kind: 'table',
  caption, table: { model, styleId }, createdAt: 0, updatedAt: 0, ...extra });
const foot = { position: 'bottom', span: 'page' }; // across both columns, at the page's foot
const calendar = calendarTable(); // its key names the quarters the grid draws
const resources = [...pictures, // never cited: the opener and the cells draw them by id
  table('calendario', 'calendar', ':swatch{color="cream"} domeniche · :swatch{color="blush"} '
    + `Pasqua e Pasquetta · ${calendar.moons}, sul mese sinodico medio: un giorno prima o dopo `
    + 'è possibile. Per tradizione in crescente si semina ciò che fruttifica sopra terra, in '
    + 'calante le radici.', calendar.model, 'calendario', { placement: foot }),
  table('consociazioni', 'table', 'Consociazioni tra dieci ortaggi', companionTable(companions),
    'matrice', { placement: foot, note: ':swatch{color="leaf"} + favorevole · '
      + ':swatch{color="blush"} − da evitare · :swatch{color="cream"} nessun effetto noto. '
      + 'Indicazioni della tradizione orticola.' }),
  // Each part of a split table repeats its caption, so the key goes there; the note ends the last.
  table('semine', 'table', 'Semine al Nord e al Centro, in pianura e collina: '
    + ':swatch{color="ochre"} in semenzaio protetto · :swatch{color="green"} in piena terra · '
    + ':swatch{color="brown"} trapianto o messa a dimora', sowingChart(sowing), 'semine', {
    placement: chartPlacement, note: 'Al Sud e lungo le coste le date si anticipano di '
      + 'due-quattro settimane; in montagna si ritardano.' }),
];

ينضّد :swatch{color="leaf"} مربعًا بثلاثة أرباع حجم الحرف، مملوءًا بمدخل من لوحة الألوان ومحاطًا بلون النص؛ وتستعمله هذه الصفحات في النص الجاري، وفي تعليقين، وفي ملاحظة. ومفتاح المخطط يوضع في تعليقه، لأن كل جزء من الجدول المنقسم يكرر التعليق، بينما لا تُنضَّد الملاحظة إلا تحت الجزء الأخير. والتقويم نوع مورد قائم بذاته بسابقة تعليق فارغة، فيبدأ تعليقه بالمفتاح بدل تسمية Tabella. ويضع position: 'bottom' مع span: 'page' التقويم والمصفوفة عبر العمودين في أسفل صفحتيهما. والصفحة 28 هي آخر صفحة نص. وفي آخر صفحة من الفصل يصعد العنصر العائم بعرض الصفحة إلى سطر واحد تحت النص، ولهذا تنتهي المصفوفة قبل الهامش السفلي بـ10 مم؛ ومع layout.hugClosingFloats: false تبقى في أسفل الصفحة.

#5 · أسلوب للدار ونسخة لكل جدول

script.js · الأسطر 134–145في الشيفرة الكاملة
const tableStyle = { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
  headerBackground: col('ink'), headerColor: col('paper'), headerFontFamily: LABEL,
  headerFontSize: pt(7), bodyFontSize: pt(8.5), cellPadding: mm(1.2),
  // An Italian document's split table says '(segue)' and 'Continua'; this spells the second out.
  continuesMarker: 'Continua alla pagina seguente' };
const tableStyles = [
  { id: 'calendario', bodyFontFamily: DISPLAY, bodyFontSize: pt(15), cellPadding: mm(1.4) },
  { id: 'matrice', rules: 'grid', borderColor: col('paper'), borderWidth: pt(2), // tiles
    headerBackgroundEnabled: false, headerColor: col('ink'), headerFontSize: pt(6.8) },
  { id: 'semine', rules: 'grid', borderColor: col('paper'), borderWidth: pt(1),
    bodyFontSize: pt(7.8), headerFontSize: pt(6.6), cellPadding: mm(1.1) },
];

يحدد tableStyle نمط الدار: رأس بلون الحبر بتسميات بلون الورق بخط Commissioner، وخطوط رفيعة بين الصفوف، والسطر الذي يختم كل جزء من جدول مقسوم. يختم المستند الإيطالي الجزء بـContinua ويضيف (segue) إلى تعليق الجزء التالي؛ أما التقويم فيكتب الأولى كاملة: Continua alla pagina seguente. وكل نمط مسمّى لا يذكر إلا ما يغيّره جدوله. ينضّد التقويم أيامه بخط Gilda Display بحجم 15 نقطة؛ وتُسقط المصفوفة تعبئة الرأس؛ وترسم المصفوفة والمخطط خطوط الشبكة بلون الورق، بعرض نقطتين ونقطة واحدة، فتقطّع تعبئاتهما إلى مربعات.

#6 · يُفتتح الشهر بلوحة

script.js · الأسطر 149–169في الشيفرة الكاملة
const ART_H = 92, AIR = 5, BEARING = 1.5; // mm: painting, air under it, side bearing of the 84 pt M
const pin = (to, edge, x, y, size) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
  ...(size && { size }) }); // to: 'page', or '#id' of an element listed before
const text = (id, content, family, size, color, placement, extra) => ({ kind: 'text', id,
  content, fontFamily: family, fontSize: pt(size), color: col(color), placement,
  align: placement.anchor.edge.endsWith('right') ? 'right' : 'left',
  overflow: 'wrap', ...extra }); // a long line takes a second one, in the heads too
const caps = (s) => ({ fontWeight: 600, textTransform: 'uppercase', letterSpacing: pt(s / 5) });
// minHeight: a floor under what the painting reserves, the first grid line AIR or more below it.
const OPENER_H = pt(LEAD * Math.ceil((ART_H + AIR - PAGE.top) / (LEAD * 25.4 / 72)));
const opener = { enabled: true, minHeight: OPENER_H, slot: { elements: [
  { kind: 'image', id: 'art', resourceId: 'campo',
    placement: pin('page', 'top-left', 0, 0, { width: mm(PAGE.w), height: mm(ART_H) }) },
  text('kicker', '{attr.kicker}', LABEL, 8.5, 'red', pin('page', 'top-left', PAGE.inner, 12),
    caps(8.5)), // page 1 is a recto: its inner margin is on the left
  text('title', '{titleText}', DISPLAY, 84, 'ink', pin('#kicker', 'below', -BEARING, 1),
    { lineHeight: 1 }), // a multiple of the size: set solid
  text('proverb', '{attr.proverb}', TEXT, 12.5, 'ink',
    pin('#title', 'below', BEARING, 1, { width: mm(140) }), { italic: true, lineHeight: 1.3 }),
  text('source', '{attr.source}', LABEL, 7, 'ink', pin('#proverb', 'below', 0, 1.6), caps(7)),
] } };

يُرسم عنوان المستوى الأول من خانة عناصر. اللوحة المائية عنصر صورة في رأس الصفحة، والعنوان التمهيدي والمثل ومصدره تأتي من سمات العنوان. يحجز تصميم العنوان حتى أسفل اللوحة، وminHeight حدّ أدنى يقع تحته بقليل: 92 مم من اللوحة و5 مم من الفراغ، ناقص الهامش العلوي البالغ 22 مم، تساوي 75 مم، تُقرَّب صعودًا إلى 16 سطرًا بارتفاع 14 نقطة (79 مم). يقع أول سطر من النص على بعد 101 مم من أعلى الصفحة، تحت التربة بـ9 مم. ويتحرك العنوان 1.5 مم إلى اليسار، وهو الفراغ الجانبي لحرف M في خط Gilda Display بحجم 84 نقطة، فتصطف زائدة M مع العنوان التمهيدي؛ ويعود المثل إلى الوراء بالمقدار نفسه.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 035 · Garden almanac: calendar grid and landscape chart ═════
// https://postext.dev/en/cookbook/garden-almanac
// Code: MIT · Text: original, Italian (CC BY 4.0) · Field: diffusion models · Icons: CC BY 4.0
// Fonts: Piazzolla, Gilda Display, Commissioner (SIL OFL 1.1) · Needs postext ≥ 1.57.0
import {
  buildDocumentWithFonts, prepareFonts, renderPageToCanvas, registerResourceImage, parseTSV,
  mergeCells, setCellContent, setCellBackground, setCellImage, setAlignment,
} from 'https://esm.sh/postext';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'garden-almanac';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#262a22', paper: '#fbf8ef', // a green-black on unbleached paper
  red: '#a2372a', // Sundays and feasts, as almanacs print them; kickers and labels
  green: '#5b8a32', ochre: '#d39a2e', brown: '#7a5230', // sown outdoors, in a seedbed, planted
  leaf: '#bfdaa2', blush: '#f3cdbd', cream: '#e9ddc1', // good pairs, bad pairs, neutral pairs
  sky: '#cfe2e6', rule: '#cfc6b2', muted: '#6b6e63' }; // sky and work box; hairlines; notes
// col() links a colour to its palette entry; the hex is the value the entry holds.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.red }) // the defaults' id
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [TEXT, DISPLAY, LABEL] = ['Piazzolla', 'Gilda Display', 'Commissioner'];
const PAGE = { w: 210, h: 280, top: 22, bottom: 21, inner: 18, outer: 16 }; // mm, mirrored
const LEAD = 14; // pt: the body's leading and baseline grid
const at = (row, column) => ({ row, col: column });
const span = (r0, c0, r1, c1) => ({ start: at(r0, c0), end: at(r1, c1) });
const chip = (text, style) => `:chip[${text}]{style="${style}"}`;

// #region answer: a crops × fortnights chart, turned to landscape on pages of its own
// The chart's `placement` (#region resources): a quarter turn makes it a page-span float on
// pages of its own, flush to the spine; rows past the page's width go on under a repeated head.
const chartPlacement = { rotate: 'ccw' }; // a float: 'here' ignores the turn
const MONTHS = ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'];
const SEASONS = [['INVERNO', 2], ['PRIMAVERA', 3], ['ESTATE', 3], ['AUTUNNO', 3], ['INVERNO', 1]];
const STATES = { S: 'ochre', C: 'green', T: 'brown' }; // seedbed, sown outdoors, planted out
const fortnight = (key) => MONTHS.indexOf(key.slice(0, 3)) * 2 + Number(key[3]); // 'mar2' → 6
function sowingChart(data) { // 'Pomodoro: S feb2–mar2, T apr2–mag2'; a bare line is a family
  const row = (first, isHeader = false) => [first, ...Array(24).fill('')]
    .map((content) => ({ content, isHeader }));
  let m = { headerRowCount: 2, columnWidths: [30, ...Array(24).fill(8.5)], // mm, as weights
    rows: [row('', true), row('', true)] };
  for (const line of data.trim().split('\n')) {
    const [name, plan] = line.split(': ');
    const r = m.rows.push(row(plan ? name : chip(name.toUpperCase(), 'famiglia'))) - 1;
    if (!plan) { m = mergeCells(m, span(r, 0, r, 24)); continue; } // a family heads its crops
    for (let f = 1; f <= 24; f++) { // every other month tinted, so a column reads down the page
      if ((f - 1) % 4 < 2) m = setCellBackground(m, at(r, f), col('cream'));

يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)

تنويعات

#أدر المخطط باتجاه عقارب الساعة

يتجه الرأس حينئذ نحو الحافة اليمنى للصفحة، ويدير القارئ الكتاب في الاتجاه الآخر.

-const chartPlacement = { rotate: 'ccw' }; // a float: 'here' ignores the turn
+const chartPlacement = { rotate: 'cw' }; // a float: 'here' ignores the turn

أخطاء شائعة

خطأ شائع

الخلايا المدمجة تحتاج إلى خلايا نائبة hiddenBy: استخدم mergeCells

تُوزَّع الخلايا بحسب موضعها في مصفوفة الصف، فالخلية المدمجة تحتاج إلى خلايا نائبة معلَّمة بـ hiddenBy حيث تمتد؛ وحذفها، كما يفعل HTML، يزيح كل الأعمدة التالية. ابنِ الدمج بـ mergeCells. ومنذ postext 1.5 يُبلَّغ عن الجدول غير المنتظم الشبكة في doc.contentWarnings تحت raggedTableGrid، ويعلّم parseTSV(text, { headerRows }) صفوف الترويسة. جداول من البيانات →

  • الصورة في خلية جدول تُرسم دائمًا فوق نص الخلية وتُحاذى مثله. لتضع أيقونة إلى جانب رقم، اجعل للأيقونة عمودًا خاصًا بها، كما يفعل التقويم مع القمر.
  • الملاحظة تحت الجدول المنقسم لا تظهر إلا تحت جزئه الأخير، فالمفتاح الذي يحتاجه كل جزء مكانه التعليق.

الحقوق

الوصفة
Ignacio Ferro
النص
  • The Italian text of the March pages, with the table captions, the notes and the colophon, written for this recipe · Ignacio Ferro · CC BY 4.0
  • The proverb “Marzo asciutto, aprile bagnato, beato il villan che ha seminato”, a traditional Italian saying · Proverbio contadino · ملك عام
الصور
  • The opener’s field of seedlings in March, a watercolour · Generated With Diffusion Models · أصلي
  • The moon’s quarters and the ten crops, drawn in code in the page’s palette · Ignacio Ferro · CC BY 4.0
الخطوط
Piazzolla (SIL OFL 1.1) · Gilda Display (SIL OFL 1.1) · Commissioner (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox