باختصار
مطلع «مقدمة» ابن خلدون في طبعة عربية محقّقة حديثة: صفحات التقديم مرقّمة بالحروف، والمتن بالأرقام، والحواشي يبدأ عدّها من الواحد في كل صفحة.
ما الذي ستنضده
إحدى عشرة صفحة من طبعة عربية محقّقة حديثة للفصل الأول من مقدمة ابن خلدون، في فضل علم التاريخ. صفحات المقدمات مرقّمة بحروف أبجد، كما تفعل طبعات القاهرة وبيروت: صفحة العنوان أ، وظهرها ب لبيانات النشر، ثم مقدمة المحقّق ج ود. ويبدأ المتن من ١ في الصفحة الفردية التالية. تقع حواشي المحقّق أسفل كل صفحة، مرقّمة (١)، (٢)، (٣) ويبدأ عدّها من جديد في كل صفحة، تحت خط قصير على اليمين؛ تشرح الغريب، وتعرّف بمن يذكرهم ابن خلدون من أعلام وأماكن، وتذكر السورة ورقم الآية لكل آية يستشهد بها. ويختم الكتابَ فهرسُ أعلام مرتّب كما تُرتَّب الفهارس العربية، دون «ال» التعريف. والحواشي والمقدمة مكتوبة لهذه الوصفة.
تجيب هذه الوصفة عن
- كيف أرقّم الصفحات التمهيدية لكتاب عربي بالحروف الأبجدية (أ، ب، ج)؟
- كيف أرقّم الحواشي السفلية العربية لكل صفحة، بين قوسين: (١)؟
الجواب المختصر
// The page counter starts in abjad letters: the title page is أ, its back ب, the editor's
// introduction ج and د. Before the text, two directives in the Markdown count again from 1,
// in the document's digits (١ ٢ ٣ in an `ar` document), on the next odd page:
// :::pagebreak{parity="odd"}
// :::numbering{format="arabic-indic" startAt=1}
// {pageNumber} prints each page's own label, so one footer and one header serve both runs.
const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
// The editor's notes: numbered again on every page, written «(١)», raised after the word in
// the text and on the line at the head of the note. The rule over the notes and each note's
// number stand on the start side, the right, because the page runs right to left.
const footnotes = {
numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
fontSize: pt(10.5), lineHeight: pt(18.5), color: col('ink'), textAlign: 'justify',
spaceAbove: pt(14), spaceBelowRule: pt(6),
separator: { width: 0.28, lineWidth: pt(0.6), color: col('rule') },
};
المكونات
- الميزات
- الحواشي السفليةأنماط الترقيم العربيةترقيم روماني للصفحات التمهيديةأشكال الأرقام في الأعداد المولَّدةالنص من اليمين إلى اليساركتب مجلّدة من اليمينالخطوط العربيةالعربية لغةً للمستندأنماط العناوينسمات العنوانصفحات افتتاح مصمَّمةالترويسات وأرقام الصفحاتالترويسات بحسب دور الصفحةالفهرس الأبجدي في آخر الكتابفهرس يُرتَّب دون أداة التعريفأنماط الفقراتلوحة ألوان دلاليةالتصدير إلى PDFالخطوط المضمَّنة في PDF
- الخطوط
- Amiri, Aref Ruqaa (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · سلسلتان من أرقام الصفحات وحواشٍ لكل صفحة
الشيفرة هي الجواب المختصر أعلاه. يبدأ page.pageNumbering الكتاب بـ'abjad'، أي الحروف بترتيب أبجد، وهـ للخامسة. وقبل المتن يعيد توجيهان العدّ من جديد في الصفحة الفردية التالية بأرقام المستند (:::numbering، الأرقام وأنماط الترقيم). وتأخذ الحواشي numbering: 'page' وmarkerTemplate بقيمة '({n})' وnoteNumberPosition: 'inline'، فترتفع العلامة في المتن وتبدأ الحاشية برقمها على السطر (الحواشي السفلية).

#2 · فهرس يتخطّى أداة التعريف
// Marks in the text, `:index[المسعودي]`, `:index[الطّبريّ]{term="الطبري"}`. With
// ignoreArticle, المسعودي files under م and الطبري under ط; ابن الكلبي stays under ا.
// It is the default when the index sorts in Arabic: written out here to say so.
const index = { ignoreArticle: true, fontFamily: NASKH, fontSize: pt(11), lineHeight: pt(17),
color: col('ink'), groups: { fontFamily: NASKH, fontWeight: 700, fontSize: pt(13),
color: col('accent'), marginTop: pt(8) } };
const indexStyle = { id: 'index', numbered: false, toc: false, span: 'page',
breakBefore: { enabled: true, parity: 'any' },
layout: { layoutType: 'double', gutterWidth: mm(10) } }; // two columns under the title
تُعلَّم الأعلام في المتن، :index[المسعودي]، ويطبعها :::index في الآخر. مع ignoreArticle يقع «المسعودي» تحت الميم و«الطبري» تحت الطاء، ويبقى «ابن إسحاق» تحت الألف؛ وتحيل إحالة «انظر» من «إسرائيل» إلى «يعقوب» (المحتويات والفهرس). وأرقام الصفحات في الفهرس هي تسميات الصفحات، فالعَلَم المذكور في المقدمة يُقرأ رقمه ج.
#3 · ترويسات فوق خط
// Running heads are physical. In a book bound on the right the verso (even) is the right
// page: its outer edge, the folio's, is the right one, and its text block starts INNER mm
// from the left edge; the recto (odd) mirrors it.
const HEAD_Y = 14; // mm from the trim
const blockX = (parity) => (parity === 'even' ? INNER : OUTER); // the text block's left edge
const heads = (parity, content) => [
text(`${parity}-head`, content, NASKH, 10.5,
{ ...at('top-left', blockX(parity), HEAD_Y, 'page'), size: { width: mm(MEASURE) } },
{ color: col('muted'), parity, pages: 'body' }),
text(`${parity}-folio`, '{pageNumber}', NASKH, 11.5, parity === 'even'
? at('top-right', -OUTER, HEAD_Y, 'page') : at('top-left', OUTER, HEAD_Y, 'page'),
{ parity, pages: 'body', align: parity === 'even' ? 'right' : 'left' }),
{ ...rule(`${parity}-rule`, HEAD_Y + 7, MEASURE, 'top-left', 'page', blockX(parity)),
parity, pages: 'body' },
];
const header = { elements: [...heads('even', '{title}'), ...heads('odd', '{chapterTitle}')] };
const dropFolio = (pages) => text(`folio-${pages}`, '{pageNumber}', NASKH, 11.5,
at('bottom', 0, -12, 'page'), { pages });
const footer = { elements: [dropFolio('opener')] }; // on the openers, under the text
// Front matter: no running heads, the abjad folio centred at the foot of every page.
const front = { id: 'front', numbered: false, toc: false,
breakBefore: { enabled: true, parity: 'any' }, header: { elements: [] },
footer: { elements: [dropFolio('all')] }, advancedDesign: titleOnly(22) };
على الصفحة الزوجية عنوان الكتاب، وعلى الفردية عنوان الفصل، فوق خط رفيع بعرض كتلة النص، ورقم الصفحة عند الطرف الخارجي. وفي كتاب مجلّد على اليمين تكون الصفحة الزوجية هي اليمنى، فيذهب رقمها إلى أعلى اليمين (ترتيب الصفحات والتجليد على اليمين). أما صفحات الافتتاح والمقدمات فتأخذ رقمًا موسّطًا في أسفل الصفحة بدلًا من ذلك.
#4 · صفحة العنوان وظهرها
const onPage = (y) => at('top', 0, y, 'page');
const blind = { numbered: false, toc: false, span: 'page', runningChapter: false,
breakBefore: { enabled: true, parity: 'any' }, header: { elements: [] },
footer: { elements: [] } }; // blind folios: أ and ب count, but do not print
const titlePage = { id: 'title', ...blind, advancedDesign: design([
text('book', '{attr.book}', NASKH, 14, onPage(44), { color: col('muted') }),
rule('rule-top', 58, 40, 'top', 'page'),
text('title', '{titleText}', RUQAA, 44, onPage(64), { fontWeight: 700,
color: col('accent'), lineHeight: 1.3 }),
rule('rule-foot', 92, 40, 'top', 'page'),
text('author', 'تأليف {author}', NASKH, 15, onPage(100), { fontWeight: 700 }),
text('years', '{attr.years}', NASKH, 12, onPage(110)),
text('part', '{attr.part}: {subtitle}', NASKH, 13, onPage(132)),
text('editor', '{attr.editor}', NASKH, 12, onPage(178), { color: col('accent') }),
text('latin', '{attr.latin}', NASKH, 9.5, { ...onPage(196), size: { width: mm(110) } },
{ color: col('muted'), direction: 'ltr' }), // a Latin line: its own direction
], 0) };
const imprintPage = { id: 'imprint', ...blind, advancedDesign: design([
text('edition', '{attr.edition}', NASKH, 11, onPage(170)),
text('imprint', '{attr.imprint}', NASKH, 9, { ...onPage(180), size: { width: mm(100) } },
{ color: col('muted'), lineHeight: 1.45, direction: 'ltr' }),
], 0) };
صفحة العنوان وبيانات النشر على ظهرها نمطا عنوان لا شيء فيهما من النص الجاري: تأتي أسطرهما من سمات العنوان، فتكون أسطر بيانات النشر اللاتينية، التي تتغير مع الطبعة، سمة واحدة في Markdown.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 113 · A critical edition (taḥqīq) with notes per page ═══════
// https://postext.dev/en/cookbook/tahqiq-critical-edition
// Code: MIT · Text: Ibn Khaldūn, al-Muqaddima, ar.wikisource (PD) · Pictures: none
// Fonts: Amiri, Aref Ruqaa (SIL OFL 1.1) · Needs postext ≥ 1.25.0
import { buildDocument, withLoadedFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'tahqiq-critical-edition';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// A modern Cairo taḥqīq: black Naskh on a cream paper, headings and rules in one dark red.
const palette = {
ink: '#1e1a16', // text and notes: a warm near-black
accent: '#8a2a1d', // headings, the title, the index letters
rule: '#8c7a62', // hairlines: the rule under the running heads, the rule over the notes
muted: '#5e564c', // running heads, the imprint
paper: '#fbf8f0', // a cream paper
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
const NASKH = 'Amiri'; // text, notes, headings in bold, running heads, index
const RUQAA = 'Aref Ruqaa'; // display: the title on the title page
const [W, H] = [170, 240]; // mm: 17 × 24 cm, the size of most Cairo and Beirut editions
const [TOP, INNER, OUTER] = [22, 20, 16]; // mm; `left` is the inner margin on both pages
const MEASURE = W - INNER - OUTER; // 134 mm
const [SIZE, LEAD] = [13, 22.5]; // pt: 1.73 ×, so the few vowels marked clear the line above
// #region answer: abjad folios for the front matter, Arabic-Indic from the text, notes (١)
// The page counter starts in abjad letters: the title page is أ, its back ب, the editor's
// introduction ج and د. Before the text, two directives in the Markdown count again from 1,
// in the document's digits (١ ٢ ٣ in an `ar` document), on the next odd page:
// :::pagebreak{parity="odd"}
// :::numbering{format="arabic-indic" startAt=1}
// {pageNumber} prints each page's own label, so one footer and one header serve both runs.
const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
// The editor's notes: numbered again on every page, written «(١)», raised after the word in
// the text and on the line at the head of the note. The rule over the notes and each note's
// number stand on the start side, the right, because the page runs right to left.
const footnotes = {
numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
fontSize: pt(10.5), lineHeight: pt(18.5), color: col('ink'), textAlign: 'justify',
spaceAbove: pt(14), spaceBelowRule: pt(6),
separator: { width: 0.28, lineWidth: pt(0.6), color: col('rule') },
};
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#استعمل حساب الجُمَّل
يكتب 'arabic-abjad' الأعداد الأبجدية الجمعية بدل سلسلة الحروف البسيطة: الصفحة الحادية عشرة يا، لا ك.
-const pageNumbering = { format: 'abjad', startAt: 1 }; // أ ب ج د هـ و ز ح…
+const pageNumbering = { format: 'arabic-abjad', startAt: 1 }; // … ط ي يا يب#رقّم الحواشي على امتداد الفصل
يعدّ numbering: 'chapter' الحواشي متصلة من صفحة إلى صفحة، كما تفعل بعض الطبعات القديمة.
- numbering: 'page', markerTemplate: '({n})', noteNumberPosition: 'inline',
+ numbering: 'chapter', markerTemplate: '({n})', noteNumberPosition: 'inline',أخطاء شائعة
خطأ شائع
اوسم الكتاب العربي بـ 'ar'، لا بـ LANG
نسختا الوصفة هما en وes، لكن المثال العربي عربي في كلتيهما: `locale: LANG` سيجعله من اليسار إلى اليمين، ويجلّده على اليسار، ويرقّم صفحاته 1 2 3، ويسمّي أشكاله Figure أو Figura. ومنذ postext 1.30 صار الوسم أيضًا اللغة التي يُشكَّل بها النص (يُقاس ويُرسم ويُضمَّن بها)، فتحت وسم إنجليزي أو إسباني لا يرسم خط مثل Markazi Text الأشكال العربية لعلامتَي التنصيص « » وللنقطة، وتنكسر الأسطر في مواضع أخرى. اكتب الوسم بنفسك: 'ar' (الأرقام العربية المشرقية، عُرف المشرق)، أو منطقة مثل 'ar-EG' أو 'ar-SA'، أو 'ar-MA' أو 'ar-DZ' أو 'ar-TN' لنسخة مغاربية بالأرقام الأوروبية. أما الصفحة اللاتينية التي تقتبس العربية فقط فتحتفظ بلغتها. النص من اليمين إلى اليسار →
خطأ شائع
الخطوط العربية تحتاج إلى ملفها arabic، عبر الكتلة arabic
يقدّم Fontsource الخطوط Amiri وNoto Naskh Arabic وScheherazade New في ملف لكل مجموعة فرعية، والحروف العربية في ملف arabic. لا يجلب loadFonts إلا latin (وlatin-ext)، فيأتي النص العربي على الشاشة من خط النظام ويُقاس خطأً، ويسلّم fontsourceProvider ملف latin ذاك إلى PDF، فيطبع مربعات فارغة. اذكر كتلة الأدوات arabic، واستدعِ loadArabicFonts(FONTS, markdown) بعد loadFonts، مع ذكر كل وزن تضع به الصفحاتُ نصًا عربيًا في FONTS، وأعطِ renderToPdf القيمة fontProvider: arabicPdfProvider. الخطوط العربية →
خطأ شائع
يسري :::numbering من الصفحة التالية
يغيّر :::numbering العدّ بدءًا من الصفحة التالية التي تبدأ، لا من الصفحة الحالية. ضعه مباشرةً بعد :::pagebreak (بالزوجية odd قبل الفصل الأول) ليبدأ الترقيم الجديد حيث تريد. ترقيم روماني للصفحات التمهيدية →
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- The opening section of the Muqaddima, “On the excellence of history”, as ar.wikisource gives it (revision 610595), without its notes · Ibn Khaldūn · ملك عام
- The editor’s introduction in Arabic, the notes, the index and the imprint · Postext Cookbook · أصلي
- الخطوط
- Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


