باختصار
صفحات قليلة من «أليس في بلاد العجائب» مع ملاحظات المحرر في الهامش الجانبي. كل ملاحظة تقف بجوار الأسطر التي تشرحها، ويدل عليها حرف ملوّن.
ما الذي ستنضده
افتتاح الفصل السابع من Alice’s Adventures in Wonderland، حفلة الشاي المجنونة، منضَّدًا في ثلاث صفحات من طبعة محشّاة على صفحة كتاب تجاري بقياس 156 × 234 مم. يجري نص كارول في عمود واحد مضبوط بخط Unna، نحو 66 حرفًا في السطر. وفي قناة عرضها 33 مم عند الحافة الخارجية تعليقات المحرر الثمانية، كلٌّ بجوار الفقرة التي فيها حرفه، فتنزل على يمين الصفحة الفردية وعلى يسار الزوجية. التعليقات على الألفاظ والنكات خضراء، وتعليقات التاريخ حمراء، ويأخذ كل حرف في النص لون تعليقه. ويبدأ الفصل تحت لوحة مائية لمائدة الشاي مرئية من أعلى، يليها الرقم، ثم العنوان بخط Rozha One، ثم مقدمة مائلة بحرف استهلالي أخضر؛ وملاحظة هذه الطبعة في الهامش بجوار المقدمة.
تجيب هذه الوصفة عن
- كيف أنضد ملاحظات هامشية أو شروحًا بجانب الفقرة التي تشرحها؟
- كيف أضيف الحواشي السفلية؟
- كيف أصمم تخطيط عمود ونصف، فيه عمود نص عريض وعمود جانبي ضيق؟
- كيف أضيف إلى صفحة الافتتاح سطر المؤلف أو مقدمة تمهيدية أو فقرة أولى بحرف استهلالي؟
الجواب المختصر
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
// (gotcha: side-box-starts-at-fence).
const gloss = (id, hue) => ({ id,
backgroundEnabled: false, // one device: a hairline over the gloss, in its colour
stripe: { enabled: true, side: 'top', width: pt(0.5), color: col(hue) },
padding: { top: mm(1.5), right: pt(0), bottom: pt(0), left: pt(0) },
// Cormorant SC draws lower case as small capitals: the title needs no textTransform.
titleStyle: { fontFamily: LABEL, fontWeight: 600, fontSize: pt(8.5),
letterSpacing: pt(0.3), color: col(hue), gap: mm(0.8) },
// Face and colours come from bodyText. A box body also inherits its 4 mm first-line
// indent, which a gloss sets back to 0.
body: { fontSize: pt(7.8), lineHeight: pt(10), textAlign: 'left',
firstLineIndent: pt(0) } });
const calloutStyles = [gloss('note', 'lawn'), gloss('context', 'jam')]; // words, history
المكونات
- الميزات
- ملاحظات الهامشعمود هامشي للعناصر العائمةعمود ونصفهوامش متناظرةإطارات التنبيهالنص المرتفع والمنخفضصفحات افتتاح مصمَّمةشريط فصل بعرض الصفحةالنصوص والخطوط والمربعات في تصاميم الصفحةالصور في تصاميم الصفحةتثبيت عناصر التصميمالحروف الاستهلالية في صفحات الافتتاحسمات العنوانالترويسات وأرقام الصفحاتالترويسات بحسب دور الصفحةالأشكال والجداول بوصفها مواردلوحة ألوان دلاليةالتقسيم الأمثل للأسطر (Knuth–Plass)الشارات داخل السطر
- تستخدم أيضًا
- الحواشي السفليةلون الورق
- الخطوط
- Unna, Rozha One, Cormorant SC (SIL OFL 1.1)
- الأصول
tea-table-1560.jpg- The tea-table seen from above, a watercolour (Generated With Diffusion Models, أصلي)
طريقة التحضير
#1 · أعطِ الحافة الخارجية للتعليقات
الشيفرة هي الجواب المختصر أعلاه. في تخطيط العمود والنصف تمنح الخاصية sideColumnPercent: 26 العمودَ الجانبي 33 مم من 127 مم بين الهامشين، ويبقى للنص 89.5 مم بعد فاصل عرضه 4.5 مم. ويُبعد sideColumnRole: 'floats' نص كارول عن العمود الجانبي، فلا يدخله إلا ما يُوضع بـspan: 'side'. الحاشية السفلية تنتظر في أسفل العمود تحت خط؛ أما في الهامش فيقف كل تعليق على مستوى السطر الذي يشرحه، ولا تأخذ التعليقات أي سطر من عمود النص. ولا يختلف نمطا التعليق إلا في لون الخط الرفيع والعنوان، فيميّز القارئ تعليقًا على لفظ من تعليق على التاريخ قبل أن يقرأه.
#2 · اعكس الصفحة لتتبع القناةُ الحافةَ الخارجية
const PT = 25.4 / 72; // mm in a point
const [TRIM_W, TRIM_H] = [156, 234]; // mm
const [TOP, BOTTOM, INNER, OUTER] = [22, 22, 15, 14]; // mm: 38 lines of text
const page = { width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
backgroundColor: col('paper'),
// left is a recto's inner margin; mirror swaps the sides on a verso, and 'outer' moves
// the channel with them: right on a recto, left on a verso.
margins: { top: mm(TOP), bottom: mm(BOTTOM), left: mm(INNER), right: mm(OUTER),
mirror: true } };
const CONTENT_W = TRIM_W - INNER - OUTER; // 127 mm
const SIDE_W = CONTENT_W * layout.sideColumnPercent / 100; // 33 mm: the glosses' measure
const TEXT_W = CONTENT_W - SIDE_W - layout.gutterWidth.value;
مع mirror: true يتبادل الهامشان مكانيهما في كل صفحة زوجية، وينقل sideColumnSide: 'outer' القناة معهما، فتنزل التعليقات على يمين الصفحة 81 والصفحة 83 وعلى يسار الصفحة 82. ويترك هامشان علوي وسفلي بعرض 22 مم ارتفاع 190 مم، يتسع لـ38 سطرًا من 14 نقطة، ويبدأ كل تعليق على سطر من الشبكة نفسها.
#3 · سيّج كل تعليق قبل الفقرة التي يشرحها
const bodyText = { // justified and hyphenated (en-us) by default
// Copy-fitted to the 89.5 mm column: at 9.5 pt '“Have some wine,” the March Hare said in
// an encouraging tone.' fits one line. At 10.4 pt every measure from 77 to 93 mm left
// it a short last line: 'couraging tone.', 'aging tone.', 'ing tone.' or 'tone.'.
fontFamily: TEXT, fontSize: pt(9.5), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), firstLineIndent: mm(4),
// The chapter's first paragraph is set flush, though the fences of glosses a and b stand
// between the heading and it: a box that leaves the flow is not the block after a heading.
indentAfterHeading: false,
// Unna's space is narrow, 0.22 em. At the default 0.6 the line breaker set 'Alice felt
// dreadfully puzzled. The Hatter’s remark seemed to have' with its spaces at 0.69.
minWordSpacing: 0.75,
// The dictionary divides the heroine's name, 'said Al-' | 'ice indignantly' on page 81.
// The list keeps it whole wherever it stands; every other word is divided as before.
hyphenation: { exceptions: ['Alice'] } };
الإطار الذي تُكتب له span="side" على سياج :::callout يغادر التدفق ويقف في القناة على مستوى الكتلة التي تليه، لذا تُكتب كتلة كل تعليق قبل الفقرة التي فيها حرفه مباشرة، كما في المثال أدناه. التعليقان a وb مكانهما بجوار الفقرة الأولى، فتقع كتلتاهما بين العنوان وتلك الفقرة. والإطار الذي يغادر التدفق لا يُحتسب الكتلةَ التي تلي العنوان، فيضبط indentAfterHeading: false تلك الفقرة بلا إزاحة. وقد ضُبط حجم المتن على العمود: بحجم 9.5 نقطة تتسع الفقرة التي تبدأ بـ«Have some wine,» لسطر واحد عرضه 89.5 مم، بينما بحجم 10.4 نقطة تركها كل عرض من 77 إلى 93 مم بسطر أخير قصير مثل «ing tone.» أو «tone.». والمسافة بين الكلمات في Unna ضيقة، 0.22 em، ومع القيمة الافتراضية 0.6 لـminWordSpacing انضغطت المسافات في سطر من الصفحة 83 إلى 0.69 من ذلك العرض؛ وminWordSpacing: 0.75 يستبعد ذلك السطر. وفي الصفحة 81 كان القاموس يقسم اسم البطلة إلى «Al-» و«ice»، فوُضعت تلك الفقرة داخل :::paragraphs{style="whole"}، وهو نمط فيه hyphenation: false، ولا تنقسم فيها إلا كلمة «together» عند واصلة اختيارية (U+00AD) مكتوبة في النص.
:::callout{type="context" span="side" title="c · Hair"}
Tenniel drew Alice with long, loose hair. …
:::
“Your hair wants cutting,”:chip[^c^]{style="context"} said the Hatter. …#4 · اطبع كل حرف بلون تعليقه
// A letter in the text is a chip named after its gloss's type, :chip[^a^]{style="note"}:
// the Markdown has no mark for coloured text, and a chip style sets a colour. With no
// fill, outline, padding or gap the chip adds no width, so the lines break as they would
// with a plain ^a^.
const letter = (id, hue) => ({ id, backgroundEnabled: false, borderWidth: pt(0),
paddingX: pt(0), gap: pt(0), color: col(hue), bold: true });
const chipStyles = [letter('note', 'lawn'), letter('context', 'jam')];
ليس في Markdown علامة للنص الملوّن، لكن نمط الشارة (chip) يحدد لون النص، فكل حرف شارةٌ لنمطها اسمُ نوع تعليقه نفسه. يطبع :chip[^c^]{style="context"} حرف c أحمر، بحمرة الخط الرفيع وعنوان التعليق c. وبلا تعبئة ولا حدّ ولا حشو ولا فجوة لا تضيف الشارة أي عرض، وينكسر كل سطر حيث كان سينكسر مع ^c^ عادي.
#5 · افتتح الفصل تحت مائدة الشاي
const HEADPIECE = 72; // mm: the depth of the painting at the head of the page
const HEADNOTE = { size: 9.8, lead: LEAD }; // pt: the headnote keeps the body's leading
const CAPS = { text: 0.597, initial: 0.56 }; // cap heights, em: Unna and Rozha One
// The initial's size: its capital runs from the first line's cap height down to the
// last baseline it spans. At the default size it stops short of the first line's capitals.
const dropSize = (lines) => pt(((lines - 1) * HEADNOTE.lead + CAPS.text * HEADNOTE.size)
/ CAPS.initial);
const below = (id, y, width) => ({ anchor: { to: `#${id}`, edge: 'below' },
offset: { y: mm(y) }, size: { width } });
// The opener reserves the height of its lowest element, rounded up to the grid, and the
// heading's default bottom margin adds one blank line: with a four-line headnote the
// text starts on line 23. The kicker, the title and the headnote hang below the painting.
const opener = { enabled: true, slot: { elements: [
// An image element draws a resource without number or caption. It hangs from the
// trim's corner, over the top margin and both side margins.
{ kind: 'image', id: 'headpiece', resourceId: 'tea-table',
placement: { anchor: { to: 'page', edge: 'top-left' },
size: { width: mm(TRIM_W) } } },
// The numeral comes from the heading line,
// # A Mad Tea-Party {num="VII" headnote="…" …}: the excerpt stands alone, so
// {chapterNumber} would count its one heading and print 1.
{ kind: 'text', id: 'kicker', content: 'Chapter {attr.num}', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(9), letterSpacing: pt(2), textTransform: 'uppercase',
color: col('jam'), align: 'left',
placement: { anchor: { to: 'container', edge: 'top-left' },
offset: { y: mm(HEADPIECE - TOP + 8) } } }, // 8 mm under the painting's foot
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY,
fontSize: pt(40), lineHeight: 1.05, color: col('ink'), align: 'left', // wraps when longer
placement: below('kicker', 2, 'fill') },
// The drop cap opens the headnote, the editor's voice, italic and ragged; Carroll's
// text opens in the flow, justified.
{ kind: 'text', id: 'headnote', content: '{attr.headnote}', fontFamily: TEXT,
italic: true, fontSize: pt(HEADNOTE.size),
lineHeight: pt(HEADNOTE.lead), color: col('ink'),
align: 'left',
dropCap: { lines: 2, fontFamily: DISPLAY, fontSize: dropSize(2), color: col('lawn'),
gap: mm(1.5) },
placement: below('title', 5, mm(TEXT_W)) },
// The note on this edition stands in the channel, level with the headnote's top.
{ kind: 'text', id: 'edition-label', content: 'This edition', fontFamily: LABEL,
fontWeight: 600, fontSize: pt(8.5), letterSpacing: pt(0.3), color: col('muted'),
align: 'left', placement: { anchor: { to: '#headnote', edge: 'right-of' },
offset: { x: layout.gutterWidth }, size: { width: mm(SIDE_W) } } },
{ kind: 'text', id: 'edition', content: '{attr.source}', fontFamily: TEXT,
fontSize: pt(7.5), lineHeight: pt(10), color: col('muted'), align: 'left',
placement: { anchor: { to: '#edition-label', edge: 'below' }, offset: { y: mm(0.8) },
size: { width: mm(SIDE_W) } } },
] } };
خانة التصميم للعنوان تمتد عبر الصفحة كي تبلغ اللوحة حدّ القص. العنوان التمهيدي والعنوان والمقدمة تتدلى تحت اللوحة، وتحجز صفحة الافتتاح ارتفاعًا يصل إلى أدناها، مقرّبًا إلى الشبكة صعودًا؛ ويضيف الهامش السفلي الافتراضي للعنوان سطرًا فارغًا واحدًا. مع مقدمة من أربعة أسطر يبدأ النص على السطر 23، وسطر خامس كان سينقله إلى السطر 24. يأتي الرقم والمقدمة وملاحظة هذه الطبعة من سمات العنوان، {num="VII" headnote="…" source="…"}. ويأتي الرقم من هناك لأن {chapterNumber} كان سيطبع 1 في مقتطف هو وثيقة قائمة بذاتها. يفتتح الحرف الاستهلالي مقدمة المحرر المنضّدة مائلةً بحافة حرّة، ويبدأ نص كارول مضبوطًا في التدفق تحتها. ويحدد dropSize() حجم الحرف الاستهلالي بحيث يحاذي أعلاه الحروف الكبيرة في السطر الأول من المقدمة.
#6 · لوّن كل تعليق بحسب ما يشرحه
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
أخضر العشب يميّز التعليقات على الألفاظ والأقوال والنكات، وأحمر المربى يميّز الأشخاص والتواريخ وتاريخ النص. وقيمة جديدة لـjam في كائن palette نفسه تعيد تلوين تعليقات التاريخ وحروفها والعنوان التمهيدي بتعديل واحد؛ وقد اختيرت اللوحة المائية فوقها لأخضر العشب وأحمر المربى نفسيهما.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 032 · Annotated classic with margin glosses ════════════
// https://postext.dev/en/cookbook/annotated-classic-glosses
// Code: MIT · Text: Lewis Carroll (PD), glosses (CC BY 4.0) · Headpiece: diffusion models
// Fonts: Unna, Rozha One, Cormorant SC (SIL OFL 1.1) · Needs postext ≥ 1.28.0
// The mad tea-party as an annotated edition: the text keeps to one column, and its glosses stand
// in the outer margin beside the lines they explain, changing sides with the spread.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the sample document ('en')
const RECIPE = 'annotated-classic-glosses';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a lawn green and a jam red on cream paper
const palette = {
ink: '#1f1b1a', // text: a warm near-black
lawn: '#1e6f6b', // glosses on words and jokes, the drop cap
jam: '#b23a48', // glosses on history, the kicker
muted: '#6e645b', // running heads, the note on this edition
paper: '#f8f3e6', // the page, and the tablecloth
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const entry = (id, hex, name = id) => ({ id, name, value: { hex, model: 'hex' } });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => entry(id, hex)),
// The engine's defaults link to 'main-color': aimed at the green, nothing prints blue.
entry('main-color', palette.lawn, 'lawn (defaults)'),
];
// #endregion
const [TEXT, DISPLAY, LABEL] = ['Unna', 'Rozha One', 'Cormorant SC'];
const LEAD = 14; // body leading in pt: the grid of every page
// #region answer: a float-only channel at the fore-edge, and two gloss styles for it
const layout = {
layoutType: 'oneAndHalf', // one text column and a narrower side column
sideColumnPercent: 26, // of the 127 mm between the margins: a 33 mm channel
sideColumnRole: 'floats', // no text runs in it: it holds side boxes and figures
sideColumnSide: 'outer', // at the fore-edge, which mirrored margins move page by page
gutterWidth: mm(4.5), // the text column keeps 127 − 33 − 4.5 = 89.5 mm
};
// A gloss is :::callout{type="note" span="side" title="a · …"} in the Markdown.
// span="side" moves it out of the flow into the channel, level with the block after
// the fence, so the fence goes just before the paragraph that carries its letter.
// Glosses never float. One that meets the gloss above stacks under it. One that would
// run past the column's foot slides up, as far as the gloss above allows, until its
// foot sits on the foot; if it still does not fit, it waits for the next page
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#أبقِ التعليقات على يمين كل صفحة
لطبعة تُقرأ صفحةً صفحةً على الشاشة، أوقف العكس: تعني 'outer' عندئذٍ الحافة اليمنى لكل صفحة، وتبقى الترويسات في أماكنها لأنها مربوطة بحدّ القص.
- mirror: true } };
+ mirror: false } };#أرسل الملاحظات الطويلة إلى أسفل الصفحة
اكتب الملاحظة الأطول من أن يتسع لها الهامش حاشيةً سفلية، [^1] في النص وتعريفها [^1]: تحت الفقرة: ينضّدها Postext في أسفل عمود النص بعرض 89.5 مم تحت خط قصير، وتحتفظ التعليقات بالقناة. وتتولى الوصفة حواشٍ سفلية في أسفل العمود الذي يستشهد بها تنسيق تلك الحواشي.
أخطاء شائعة
خطأ شائع
يبدأ الإطار الجانبي بمحاذاة الكتلة التي تلي سياجه
في postext 1.4.1 يقف الإطار span: 'side' في العمود الجانبي على الارتفاع الذي بلغه النص عند سياجه، على سطر الشبكة التالي، وتحت أي إطار موجود هناك. ضع سياج الحاشية الجانبية قبل الفقرة التي تشرحها مباشرةً: إذا وضعته بعدها، بدأت الحاشية بجانب الفقرة التالية. والإطار الذي يتجاوز أسفل العمود ينزلق صعودًا حتى يستقر أسفله على أسفل العمود، بقدر ما يسمح الإطار الذي فوقه؛ وما لا يتسع بعد ذلك ينتظر العمود الجانبي في الصفحة التالية. ملاحظات الهامش →
- تتراصّ التعليقات بترتيب Markdown، واحدًا تحت الآخر، فيدفع التعليق الطويل التالي إلى الأسفل. في الصفحة 81 يقع الحرفان كلاهما في السطر الثاني من الفقرة الأولى: يبدأ التعليق a على مستوى الفقرة، والتعليق b تحته، على بعد خمسة أسطر من حرفه. حيث تتقارب الحروف، اجعل التعليقات قصيرة.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- Alice’s Adventures in Wonderland (1865), the opening of chapter VII, “A Mad Tea-Party” · Lewis Carroll · ملك عام
- The headnote, the eight glosses and the note on this edition · Ignacio Ferro · CC BY 4.0
- الصور
- The tea-table seen from above, a watercolour · Generated With Diffusion Models · أصلي
- الخطوط
- Unna (SIL OFL 1.1) · Rozha One (SIL OFL 1.1) · Cormorant SC (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


