Chapter 12 · Part II · The craft
Composed pages
How to write a composed page in Markdown: the page fence, opened with four colons, that chooses the template; frames and the slot attribute, which share content out among its frames; repeated slots and modules; and warnings for content that does not match the template or covers another frame
In short
Some pages are not one column of running text but a set of boxes, like a page of a school textbook with a title band, a text and three coloured boxes with photos. Postext calls them composed pages. The shape of the page is a template in the configuration, and the Markdown only says which piece of text goes into which box. This page shows how to write that Markdown: the page fence, the frames, the slot names, cards repeated in a grid and blocks stacked as modules. It also lists the warnings Postext gives when the text and the template do not match.
The template holds the form of the page; the Markdown holds its content and says which frame each piece goes to.
A composed page is laid out from a template defined in the configuration under pageTemplates: named frames (a title band, a text, a box with its photo), groups that move together, and a decoration. In the Markdown, the page is a fenced block that names its template and sends content to frames by name. Positions and sizes are never written in the Markdown, and the text is never written in the configuration, so a translation reuses the template with different words.
This page covers the Markdown and how the page is set from it. The template itself (its frames, sizes, styles and decoration) is described in Configuration › Composed pages. A document without composed pages lays out exactly as before.
#The page fence
::::page{template="tema-cajas" fondo="banda-retos"}
# La actividad económica y el dinero
Las personas utilizan :chip[recursos]{style="clave"} que se obtienen de la naturaleza…
::::A composed page is written as a page fence: it opens with a line of four colons followed by page and its attributes, and closes with a bare line of the same number of colons. Inside, three-colon containers (:::frame, :::callout, :::figure, :::columns, :::paper) open and close as they always do, so a bare ::: closes the innermost of them and never the page. A page opened with five colons (:::::page) closes with five; a line of four colons inside it is then ordinary text.
| Attribute | Effect |
|---|---|
template="…" | Required. The id of an entry of pageTemplates. |
spread | The page is a spread of two facing pages (see Spreads). It must agree with the template's spread; otherwise the template wins and spreadMismatch reports it. |
id="…", #id | An anchor: a :ref to it prints the page number of the composed page. |
palette="…" | Colours of this page's palette entries, as entry=#hex pairs separated by commas: palette="tint=#f6c3d0" for a page whose boxes take the topic's tint. Every palette-linked colour of its frames and decoration takes them, overriding the template's palette. Since postext 1.42. |
a flag such as frontmatter | An attribute a template element names in when or unless: frontmatter on a title page leaves off the folio and the band the template draws on body pages. Written alone it is set; so it is with any value but false. See Drawn when the page says. Since postext 1.50. |
| any other | A value the template reads as {attr.name}, such as a background picture chosen page by page: fondo="banda-retos" with resourceId: "{attr. in the decoration. |
A composed page always starts a new page (or spread), and the text after its closing fence starts on the next one.
The three-colon :::page{split=…} is a comic page (see Comics) and keeps that meaning. A three-colon :::page that carries template= is still read as a comic page, and the warning pageFenceLength says that a composed page needs four colons.
When a fence is missing, the parser recovers without losing text:
- a page left open runs to the end of the chapter and is reported as an unclosed container at its opening line;
- a
::::pageline met while a page is open closes the open page there first (reported the same way); - the closing fence closes any frame or box still open inside the page, reporting each one;
- a closing line with a different number of colons does not close the page: it stays in the text, where you can see it.
#Frames and slots
:::frame{slot="dinero" label="El dinero"}
Es el instrumento utilizado como medio de pago…
Hasta hace pocos años, lo más normal era pagar con dinero en **efectivo**…
:::A slot names the frame a piece of content goes to: it matches the name of a frame in the template. :::frame{slot="…"} sends everything inside it to that frame. Its body is full Markdown: paragraphs, lists, headings, chips, ::resource embeds, :ref references, footnotes, :::columns and nested callouts. label and title set the text of the frame's tab or title, as they do for a :::callout; the frame's look comes from the callout style the template gives it, and a piece can name a look of its own (see Frame looks).
A single block can name its own slot:
| Block | Written |
|---|---|
| A heading | ## Retos {slot="retos-titulo"} |
| A resource embed | ::resource{id="dinero-pago" slot="dinero-fotos"} (the two attributes, in any order) |
| A code listing | ```js {slot="codigo"} |
| A box or any other container | :::callout{type="nota" slot="aside"}: the whole box goes to the slot |
| A figure | :::figure{resource="mapa" slot="mapa"} (see below) |
How the content is shared out:
- Several pieces with the same slot are joined in Markdown order, except in a repeating grid, where each piece is a card of its own (see Repeated slots).
- Content with no slot goes to the template's flow frame (the frame marked
flow). - A heading with no slot goes first to the frame that
takesits level (takes: "h1"), if the template has one, so the title of a textbook topic is just# Titleat the top of the page. - A
:::tocwith no slot goes to the frame thattakes: "toc", if the template has one (see The contents in a frame, below). - Content that names a slot the template does not have goes to the flow frame and is reported (
slotUnknown).
A slot outside a composed page is read but has no effect.
#Repeated slots
When the template draws a card once and lays it in a grid as many times as the page needs (a group with repeat, see Configuration › Grids that repeat a frame set), each :::frame that names the card's main slot is one card, in the order written:
::::page{template="fotos"}
# Animals of the river
:::frame{slot="foto"}
::resource{id="garza"}
:::frame{slot="pie"}
The heron
:::
:::
:::frame{slot="foto"}
::resource{id="nutria"}
:::frame{slot="pie"}
The otter
:::
:::
::::- Members of the card. Inside the card's piece, a block or a
:::framethat names another frame of the set (herepie, the caption pill) goes to that frame of the same card. Everything else goes to the card's main frame. - One block, one card. A
::resource{id="…" slot="foto"}on its own, outside any container, is a card too. - Names. The cards are numbered from 1: the frames of the second card are
foto[2]andpie[2], and so they appear in warnings, the reflow log and the Sandbox. - How many. The page has as many cards as pieces. A Spanish edition with five animals and an English one with four use the same template. A grid with
repeat.maxtakes that many; each piece over raisesrepeatOverflowand goes to the flow frame.
A frame of the set is reported as slotEmpty only when no card of the page fills it. A repeated frame never takes a heading, and it is never the flow frame.
#Frame looks
A piece can wear a named look: a set of colours the configuration defines in frameLooks (see Configuration › Frame looks). The Markdown names the look and the configuration says what it is. On a grid this gives each card its own colour, while every card keeps one template and one style:
::::page{template="fotos"}
# Animals of the river
:::frame{slot="foto"}
::resource{id="garza"}
:::frame{slot="pie" look="rojo"}
The heron
:::
:::
:::frame{slot="foto" look="marino"}
::resource{id="nutria"}
:::frame{slot="pie" look="verde"}
The otter
:::
:::
::::- Where.
lookgoes on the opening line of any:::frame{slot="…"}piece. A card's main piece (here the second photo's frame) and a member nested in it (each pill) name their own. - What it changes. The look is laid over the frame's style and the template's own colours, for that piece only: the other cards keep theirs. Text that goes on in another frame (a chain, a continuation page) keeps the look.
- An unknown id. An id that
frameLooksdoes not have raiseslookUnknownat the attribute, with the nearest id, and the frame keeps its colours.
#Modules in a page
A page template with a modules group (modules: true, see Configuration › Modules) takes its blocks from :::module containers, laid one under another in the order written. The module's template draws the block; the container holds its words:
::::page{template="tema"}
# The river
:::module{template="caja"}
:::frame{slot="texto" label="Did you know?"}
A river begins in the mountains, where rain and snow gather into streams.
:::
::resource{id="rio" slot="foto"}
:::
:::module{template="arbol" name="ramas"}
:::frame{slot="raiz"}
The river
:::
:::frame{slot="izq"}
The water it carries
:::
:::frame{slot="der"}
Life on its banks
:::
:::
::::templatenames a template withrole: 'module'.nameis optional: it names the module's instance, so its frames areramas.raiz,ramas.izq. Without it the instance is<template>[n], the module's count among the page's modules of that template:arbol[1].raiz. A name already taken on the page, or one with a space,.,#,[or], is replaced by that default (moduleNameRejected).- Slots inside a
:::moduleare the module's own:slot="raiz"reaches theraizframe of this module, and two modules of one template on a page keep their words apart. Content that names no slot goes to the module's flow frame, and a heading to the module frame thattakesits level; with neither, to the page's flow frame. - Order. The modules stack in Markdown order, so another page sets the same blocks in another order, or with one more tree, with no new template.
- Side by side. When the modules group is a row or a grid, or holds groups of its own (
within), the same blocks stand side by side: two:::module{template="aviso"}followed by four:::module{template="tarjeta"}make a row of two boxes over a 2 × 2 of cards. The Markdown still says only which modules come and in what order (see Configuration › Modules). Since postext 1.51 a group may also lie inside a row, so a box stands beside a column of cards, and the modules of a row share its room bygrowandshrink. - A
:::moduleoutside a page fence is a plain box of its content. A module inside a module is not supported (moduleNested).
#Example
The page of a school textbook, with a title band, a text with its list and three coloured boxes, each with its photo beside it:
::::page{template="tema-cajas" fondo="banda-retos"}
# La actividad económica y el dinero
## La actividad económica
Las personas utilizan :chip[recursos]{style="clave"} que se obtienen de la naturaleza…
- Las :chip[empresas.]{style="clave"} Ofrecen bienes y servicios a cambio de un beneficio.
- Las :chip[personas y familias.]{style="clave"} Adquieren lo que ofrecen las empresas…
:::frame{slot="dinero" label="El dinero"}
Es el instrumento utilizado como medio de pago, ya que su valor es conocido…
:::
::resource{id="dinero-pago" slot="dinero-fotos"}
:::frame{slot="gasto" label="El gasto"}
- **Fijo:** es el que se produce todos los meses…
- **Variable:** puede cambiar según las necesidades…
:::
::resource{id="gasto-compras" slot="gasto-fotos"}
:::frame{slot="ahorro" label="Préstamos y ahorro"}
Si necesitas o quieres comprar algo muy caro…
:::
::resource{id="ahorro-balanza" slot="ahorro-fotos"}
::::The title goes to the frame that takes h1; the subheading, the paragraph and the list go to the flow frame; each box and each photo go to the frame of their slot. The Catalan edition is the same lines with other words: the template, the slots and the photos do not change.
#How the page is set
A composed page takes a page of its own (role composed for the pages filter of design elements). The template is chosen for the side the page falls on, so its variants.recto or variants.verso applies. Then each frame is placed and filled in turn, with the typography of the rest of the book: paragraph and heading styles, lists, chips, footnote markers and the callout style of the frame.
#Placing the frames
A frame stands in its grid cell, or where its placement puts it (an anchor, an edge and an offset, as for a design element), or, with neither, at the top-left corner of the template's area, as wide as the area. A frame anchored to another one ("to": "#dinero") is placed after it and moves with it: below hangs it under the other frame, right-of beside it, and a corner such as top-right pins it to that corner of the other frame's box.
Its height is fixed (a length or a percentage), fill (down to the edge of the area), or auto, the default: the height of the content it receives, between minHeight and maxHeight, and never past the foot of the area. A frame taller than its content places it as verticalAlign says (top, middle, bottom, or justify to spread the space between its blocks). The frame's callout style draws its background, border, rounded corners, stripe and icon at the frame's full size; the label of the :::frame fence prints in the style's tab.
#The flow frame and headings
Content that names no slot goes to the frame marked flow; the first heading of a level goes to the frame that takes it. The frames of a page are read in the order their content first appears in the Markdown, each one whole: a screen reader, the tagged PDF and the reflowable outputs read a box after the text that opens the page, not in the middle of it.
A heading set in a frame keeps the design of its level or heading style (a tab, a band, {titleText} set by the design), laid out at the frame's width as in a page column, and the frame makes room for the design; a frame whose text is scaled scales the design with it, a turned frame turns it. See In boxes and frames. Up to postext 1.36 such a heading was set plain.
#The contents in a frame
A frame can set the table of contents (since postext 1.42). Give the template a frame with takes: "toc" and write :::toc in the page fence, or write it inside the :::frame that names the slot:
::::page{template="contents"}
# In this unit {toc="false"}
:::toc{keep="part" levels="1-2"}
::::The frame sets the rows by the rules of the contents, as the running text does. A part has its row, drawn from toc.parts.design; an entry keeps its number, its leader and its page label, and links to the page it lists; the frame adds no paragraph spacing between entries. keep works in the frame: with overflow.continueIn: "next-page", a block of the contents that a whole frame can hold goes whole to the added page, and a block taller than the frame is cut after its head and toc.groups.minEntriesAfterHead entries, and the added page opens with the head repeated (toc.groups.continuation). The mark at the cut (overflow.mark) and the words at the head of the added page (overflow.fromMark) work as in any frame.
The title above the list is an ordinary heading, and the contents list it unless its heading style says toc: false or the heading says {toc="false"}, as in the running text. The background of the page, a colour or a picture under the whole sheet, is the template's decoration: it paints under the frames and repeats on every page the contents add. A page break between parts (toc.parts.breakBefore) works in a frame that can go on (overflow.continueIn: "next-page", or a frame with next): the frame is cut before every part but the first, though all of it would fit, and each part opens the added page or the next frame. A frame that cannot go on ignores the break. Since postext 1.43.
#Chaining frames
next sends what a frame cannot hold to another frame of the same page, and that frame to another, like threaded text frames:
{ "name": "columna-1", "flow": true, "next": "columna-2", "height": { "value": 120, "unit": "mm" } },
{ "name": "columna-2", "placement": { "anchor": { "to": "#columna-1", "edge": "right-of" } } }The text is cut between lines and goes on in the next frame, broken again at that frame's width, with nothing lost or repeated. overflow.continueIn: "#frame" means the same.
A frame breaks as the running text does. A heading never ends a piece: it goes on with the lines it introduces. A cut between the items of a list leaves at least two items on each side (one when bodyText.avoidOrphansInLists or bodyText.avoidWidowsInLists is off), and under bodyText.shortListSplit: 'avoid' a list of up to bodyText.shortListMaxItems items is not cut between its items. When no cut allows that, the piece ends before the heading or the list, or inside one of the list's items. To go on on a page added after this one, see When the text continues.
#Frames that push text
A frame with exclude: "push" keeps the text of the other frames out of its rectangle: a line of a frame that meets it is set short on the side the rectangle covers, as text wraps round a picture in the running text. A photo anchored to the corner of a box and marked push makes the box's text run beside it. A box that should keep a fixed column free for its pictures can use padding instead.
With "wrap": "contour" as well, the frame pushes with the shape of the pictures it holds rather than its rectangle: the alpha channel of a cut-out illustration, or the polygon in its resource's contour. Each line of the other frame is set as short as the shape is wide beside it, so the text of a box follows the outline of a drawing laid over it, with no line breaks or indents written line by line. Captions and other text in the pushing frame keep their boxes, a turned frame pushes with its box, and a picture whose shape is not known pushes with its box too, with a textWrap warning (reason noContour). See Document format › Contour wrap for the shape, its threshold and its margin.
{ "name": "drawing", "exclude": "push", "wrap": "contour", "layer": 2,
"placement": { "anchor": { "to": "#box", "edge": "top-right" } }, "width": { "value": 150, "unit": "mm" } }#Decoration, running heads and layers
The template's decoration (pictures, rules, boxes and short texts) is placed once the frames have their final boxes, so an element can anchor to a frame ("to": "#gasto") and follow it, and a connector can join two frames with a line that stays on them however their words move them. Its texts read the page's own attributes: fondo="banda-retos" on the page fence gives {attr.fondo}, for example a background picture chosen page by page with "resourceId": "{attr.fondo}". The running heads read them too. A template's header or footer replaces the section's, false hides it, and with neither the section's running heads print. On a right-to-left or vertical page the frames follow the mirrored or turned flow while the decoration stays on the sheet: an element placed at a start or end edge (top-start, see Element placement) stands by its frame in every edition.
Frames paint in the order of their layer: the decoration at layer 0, frames at 1 by default, a higher layer over a lower one, a negative layer under the decoration. rotate turns a frame and its content together by any angle, about the frame's centre, in the canvas, the PDF, the HTML viewer and the fixed-layout EPUB.
#Content that does not fit
A frame whose content is taller than the frame, with no next frame to go on in and no page to continue on (overflow.continueIn), keeps all of it in the document but shows only what fits: the rest is cut at the frame's foot on paged output, and the warning frameOverflow says how much. Content that no frame takes (no flow frame, or a frame missing on this side) is set in the running text on the page after the composed page.
#Outside print: HTML, EPUB and tagged PDF
Every output reads a composed page in the order of its Markdown, not in the order the template lists its frames or paints its layers.
- Reflowable EPUB. The page becomes a section (
<section class="pt-composed pt-composed-tema-cajas">) that opens with the page's page-break marker. Each frame is one block of it (<div class="pt-frame pt-frame-dinero">), placed where its content first appears in the Markdown; a frame and the frames itsnextchain goes on in make one block, and so does a frame whose content continues on added pages: the pieces are joined, a paragraph cut between two pages is one paragraph, and the added page's page-break marker stands inside it, where that page's text starts. A frame drawn in a callout style keeps that style's box: background, border, padding, body text, and itslabelas the box's title. A frame with no style is a plain block. The decoration (background pictures, cards, design text) belongs to the printed page and is left out. - Figure labels. The HTML viewer and the fixed-layout EPUB write each drawn label as text right after its picture, in the order written (
<div class="pt-figure-label">, turned by a CSS matrix), so a screen reader reads the picture's alternative text and then its words. The picture an EPUB carries does not show them. The reflowable book draws the plain ones as one SVG laid over the image (pt-label-layer, in the picture's own coordinates, so the words scale with it; since postext 1.40): words in bold or italic, the halo and the plate of their style, turned byrotate. A vertical label, and one with a formula, a chip or a mark, are left out of the SVG. The labels of a right-to-left book are drawn as they stand on the sheet (since postext 1.42): each word at the x the print measured, and a word of a right-to-left script as its own right-to-left text anchored at its right edge, so the browser joins its letters. All of them are listed after the picture, inside its figure: a list hidden from sight (pt-figure-labels pt-hidden) that a screen reader reads once. A label that is not drawn (its anchor is unknown) follows the picture's alternative text instead,A map of Europe (Madrid); Chinese and Japanese labels take(…、…), Arabic ones the Arabic comma. - HTML viewer and fixed-layout EPUB. Both show the printed page with its template applied: each frame in its box, turned by
rotate, clipped when its content overflows, painted over the frames of lower layers, the decoration at layer 0. The markup lists the frames in reading order and paints them in layer order withz-index, so assistive technology follows the Markdown while the page looks as printed. Decorative pictures are hidden from assistive technology (alt=""). The decoration's faces are among those the Sandbox embeds in an EPUB; a fixed-layout EPUB written without one of them reportsmissingFont. - Tagged PDF. The structure tree reads the frames in the same order. Each frame, or chain of frames, is a
Divholding its headings, paragraphs and lists, and the pieces of a frame continued on added pages are that sameDiv(a paragraph cut between pages is oneP, the continuation mark an artifact); each of its pictures is aFigure, followed by aDivwith onePper drawn label in the order written. A label's halo and plate are layout artifacts, so its words are read once; the decoration is a layout artifact too.
From code, a figure's labels are on its block as resourceBlock.labels: text, anchor or point, style and source range, plus layout (the lines, box, turn and look of a drawn label) and rect (where it is painted, which sourceAt answers). composedReadingOrder(composedPaintOrder(page)) lists a page's decoration and frames in reading order.
#Warnings
The checks read the Markdown and the configuration before any layout, so they show in the Checks panel as you type, in postext check and in the document's contentWarnings, each with the source range of what it concerns (see Configuration › Warnings in the document).
| Kind | Cause | Fix |
|---|---|---|
templateUnknown | The page fence names a template that is not in pageTemplates, or names none. Its slots are not checked. | Correct the id, or add the template to the configuration. |
slotUnknown | A slot="…" names no frame of the page's template (frames inherited through extends and frames of a variants page count). The content goes to the flow frame, which the warning names (frame). | Correct the slot name, or add a frame of that name to the template. |
slotEmpty | A frame of the template receives nothing on this page: no slot names it, it takes no heading, and, for the flow frame, no content is left without a slot. A frame that only receives what another frame continues into it (next) is not reported. Nor is the frame a story jumps to from an earlier page (overflow.). postext check lists it as a note. | Write content for it with its slot, or mark the frame optional: true in the template. |
pageFenceLength | A three-colon :::page carries template=. It is read as a comic page, as before. | Open the page with four colons, ::::page{template="…"}, and close it with ::::. |
spreadMismatch | The fence's spread and the template's disagree. The page is laid as the template says (see spreadMismatch). | Write spread on the fence of a spread template, or remove it for a single-page template. |
unclosedContainer | A composed page, a frame or a figure is never closed (see the recovery rules above). The Checks panel names the composed page ::::page. | Add the closing fence: as many colons as the page's opening line, or ::: for a frame or a figure. |
strayFence | A ::: after a one-line directive (:::toc…) closing nothing: dropped. | Delete the :::. |
repeatOverflow | A repeating grid holds repeat.max cards and the page gives it more (see Repeated slots). One per card over, at its slot="…": the card goes to the flow frame, or after the page. | Raise or remove max in the template, or move the extra cards to another page. |
lookUnknown | A :::frame piece writes look="…" with an id that no frameLooks entry has (see Frame looks). The frame keeps its style and its template colours. The warning names the nearest id (suggestion). | Correct the id, or add the look to frameLooks. |
moduleUnknown | A :::module names no template, a template that is no module, or the page's template has no modules group (reason). Its content goes to the flow frame. | Correct the template of the module, or give the page's template a group with modules: true. |
moduleAsPage | A page fence names a module template. Its content is set in the flow, as for an unknown template. | Name a page template on the fence and write the module inside it as a :::module. |
moduleNested | A :::module is written inside another module. Its blocks are the outer module's. | Close the outer module before opening the next one. |
moduleNameRejected | A module's name is taken by another module of the page, or holds a space, ., #, [ or ]. The module takes the name used (arbol[2]). | Give each module of the page a name of its own, made of letters, digits and dashes. |
The module warnings and repeatOverflow are since postext 1.48, lookUnknown since postext 1.50; the template side of each is described in Configuration › Overlap, repeat and module warnings.
Once the book is laid out, each of these warnings also carries the page it concerns (pageIndex), so the Checks panel and postext check give the page number next to the template, the frame or slot, and the source range.
#frameOverflow
This warning comes from the layout, not from the source checks above: it appears once the page has been set, in the Checks panel, postext check and the document's contentWarnings.
Cause. The content poured into a frame (through its slot, or as the flow frame's content) is taller than the frame, the frame has no next frame left to continue in, and none of the steps of the reflow ladder made it fit. Most often there is more text than the frame holds: a translation that runs longer than the original, or a frame held to a fixed height or maxHeight. What does not fit is cut at the foot of the frame in paged output; it stays in the document, the source map and the reflowable EPUB. The warning gives the template, the frame, the page, the document's locale, the height cut (overflowMm), configPath (the JSON pointer of the frame in the configuration, /pageTemplates/0/frames/2), the steps it tried (stepsTried), the scale its text and pictures were left at (scale, imageScale) and proposals, the changes that would make it fit.
Fix. Apply one of the proposals: each comes with its value, worked out on the page (see The warning and its proposals). Otherwise give the frame more room, chain it to another frame with next, shorten the text, or set the page with another template.
An empty frame is reported too. In a stack whose frames have nothing more to give, a frame cut below its minHeight or its fixed height (an answer space, a picture slot) overflows by the height cut, with no content at all. Its proposals lower its own minHeight, or the minHeight of a frame of its group that holds less content than that; they never take the room of another empty frame.
#frameContinuationLimit
Cause. A frame whose overflow.continueIn is 'next-page' or 'template:<id>' sent what it could not hold to an added page, and that page's frame sent the rest on again, page after page, until the composed page had added its maximum of 16 pages (see When the text continues). What is left is cut at the foot of the frame on the last added page; it stays in the document, the source map and the reflowable EPUB. The warning gives the template and frame of that page, the number of pages added (pages), the height cut (overflowMm), the frame's configPath and the page. Most often the frame that takes the content on the added page is far smaller than the text.
Fix. Give that frame more room (its height, or an overflowTemplate with a larger frame), or shorten the text. A box that runs over more than a few pages usually belongs in the running text.
#continueTargetMissing
Cause. A frame's overflow.continueIn is 'page:<id>' (see Jumping to a later page), and no page fence ::::page{id="<id>"} comes after the page the story is on: the id is misspelt, the fence lacks it, the fence attribute the rule reads ('page:{attr.sigue}') is missing, or the fence comes before (before: true). The rest continues on a page added right after, as with 'next-page'. The warning gives the template, the frame, target (the id it looked for), the frame's configPath and the page. The id may also belong to a page fence of a later chapter of the book; a chapter laid out on its own with buildDocument and no laterPageIds knows only its own pages.
Fix. Give the later page fence that id, or correct the name in continueIn or in the fence attribute it reads. A page before the story cannot take it: move that fence after the story, or name a later page.
#frameCovered
Cause. Part of a frame lies under another frame painted over it (a higher layer, or the same layer later in template order), where that frame is opaque: a caption under a photo, a tab under a cut-out picture, a box's last lines under a band. The check runs once the page is set, on the boxes the content gave the frames, so a page that is clear in Spanish can be covered in a longer edition. A frame covers with its fill (its style's background or look.background, its tab, its stripe), its pictures and its text lines; an outline covers nothing, and a frame that pushes text round the shape of its pictures (wrap: 'contour') does not cover lines with their box. What can be covered: the frame's lines, its tab and title, its pictures and tables. Words over a picture are not reported: whether they read is the contrast check's job. A cut thinner than 0.3 mm is a touch, and a pair under 1 mm² is left out.
The warning names the template, the frame, the covering frame (coveredBy, coveredByPath), the area hidden (overlapMm2), the first covered words (text) or picture (picture), the language and the page, and points at the covered frame's content. One warning per pair.
Fix. Each proposal is data, as frameOverflow's are:
layer: the covering frame'slayerset under the covered one, proposed only when that does not hide something else instead;exclude:'push'on the covering frame, so the covered text runs round it (only when body lines are hit);move:frame,dxMm,dyMm, the smallest shift of the covering frame that clears the pair, tried on the page: it is offered only when the moved frame, and the frames anchored to it, land clear of every other frame and stay inside what holds them. When no direction lands clear, or the covered frame hangs from the covering one, no move is offered.
When the overlap is meant (a drawing that reaches over the text on purpose), set overlap: 'allow' on either frame. Since postext 1.48.
#frameOutsideArea
Cause. A frame runs past what holds it: its text past the trim, where it is cut, or its fill and pictures past the bleed (with no bleed, both are the trim); or any part of it past the frame or group it is anchored inside, a note anchored inside a card (top-left of '#card' with an offset into it) that its text pushes past the card's foot. A frame anchored to an edge outside the other box (below, right-of) is never inside it. Overruns under 0.3 mm are left out.
The warning gives past ('trim', 'bleed', 'frame' or 'group'), target (the frame or group's name), excessMm (the largest overrun), sides (each side's), the language and the page.
Fix. The proposals: maxHeight, the room the frame has (not proposed for a frame held by its foot, which a smaller height does not bring in); continueNextPage with it, for a frame of text, so what no longer fits goes on; minHeight of the frame it is anchored inside, grown by the overrun; move, the shift that brings it in when it runs past one side only, offered when it lands clear of the other frames. A badge hung off its card on purpose takes overlap: 'allow'. Since postext 1.48.
#When the text grows
A composed page rearranges itself inside the limits its template declares. Write a longer text in the first box of a page whose boxes form a stack group, and the box grows to hold it while the boxes below, and the photos and decoration anchored to them, move down; no line of the template changes. A shorter text gives the box back its declared height. A frame or a decoration element marked pin stays where the template puts it, for a box that has to sit on the artwork. How stacks and rows share space, and which frame gives way first, is set in the template: see Configuration › How groups share space.
When the boxes reach the foot of the area and no frame of the group can give more space, the frame that does not fit climbs the reflow ladder below; groups add no warning of their own.
#When it still does not fit
A frame whose content does not fit tries in turn the ways its template allows to make room, and stops at the first that works. Each step is tried on top of the ones before it, in this order:
| Step | What the layout does |
|---|---|
free | The frame takes free space. A frame whose height follows its content already grows into the room its area and its group leave; a frame with a fixed height grows up to its maxHeight when it has one. |
push | Its group moves the frames after it down and the frames with shrink give space back (see How groups share space). |
scaleImages | The pictures of the frame and of the other frames of its group are set smaller, in steps of 2.5 %, down to fit.imageMinScale (80 % by default), at the largest scale that makes the content fit. The text after a picture moves up with it. |
redistribute | The other frames of its group give space back whether they shrink or not: each goes down to its minHeight, never below what its own content needs. In a row, they give width, each down to the narrowest width its own text still fits in. |
shrinkText | The frame's text is set smaller, in steps of 2.5 %, down to fit.minScale (90 % by default), at the largest scale that makes it fit. Font size, leading and spacing shrink together, as if the whole frame were set in a smaller size. A frame chained with next shrinks with the frames of its chain. fit.shrinkText: false leaves the text at its size. |
continue | The frame continues on another page (overflow., 'template:<id>' or 'page:<id>'): it is cut at its foot with its mark and the rest continues on a page added after this one (see When the text continues). Its text and pictures go back to full size, since what does not fit goes on anyway. No warning is raised. |
A frame that can continue on another page takes that step earlier: after redistribute, before scaleImages and shrinkText. A story set over several pages keeps one type size, and its last page is not set smaller than the pages before it. Its pictures and text shrink only when it cannot go on: on the last page continuation may add, or when the frame that would take the rest takes none of it. fit.preferContinue: false keeps the order of the table, for a box that should lose a few points rather than add a page.
When no step makes the content fit, the frame is cut at its foot, keeps the scales the ladder reached, and the layout reports frameOverflow. A frame on an added page that takes none of the content it receives does not send it on again (it would add pages for ever): it reports frameOverflow too, with continue among the steps tried. Each step lays the whole page out again, so the result depends only on that page: the same input gives the same page, frames that overflow are taken in template order, and a change on one composed page leaves every other page as it was. The settings are in Configuration › When content does not fit.
#The warning and its proposals
frameOverflow names the page, the template, the frame and the document's language, so a page that fits in Spanish and overflows in Catalan says so, and it lists the steps it tried. Each proposal is data, { kind, path, value }: path is the JSON pointer of the setting to change and value what to set it to, worked out from the shortfall.
| Proposal | What it changes |
|---|---|
allowShrink | fit.minScale of the frame: the largest text scale, in steps of 2.5 % down to 50 %, at which the content fits, tried on the page. When that scale divides a word wider than the frame, the proposal names the largest smaller scale that fits with every word whole and carries word: 'whole'; when no scale down to 50 % sets it whole, it keeps the largest that fits and carries word: 'divided'. With fit.shrinkText: false, also turns it on. |
raiseMax | maxHeight of the frame: its height plus the shortfall, in whole millimetres. Proposed only when the page has the room, which is tried on it. |
lowerMin | minHeight of another frame of its group (frame) that stands at its minimum with less content than that: lowered by the shortfall, never below its content. Tried on the page. |
continueNextPage | overflow.continueIn of the frame, set to 'next-page'. |
useTemplate | Another template of the book with a frame of the same name in which the content fits as it is, tried on the page in the order of pageTemplates. The trial sets the page as the build would with that template: the slots it has no frame for go to its flow frame, its own ladder runs, and it is proposed only when no frame overflows and nothing goes on to another page (since postext 1.39). A page added by continuation gets no such proposal. It is a change to the Markdown: sourceStart and sourceEnd give the range of the page fence's template value. |
shortenText | About how many characters to cut: the lines that do not fit, at the frame's characters per line. The range is the frame's content. |
postext check prints the warning with its steps and proposals in words, and --json carries the same data under the warning's data:
warning frameOverflow (chapters/03.md:12, page 17): Frame "recuadro" of template "tema" (ca) is 4.2 mm short of its content after free space, text down to 90 % — the rest is cut at the frame's foot; to fit: let its text shrink to 85 % (fit.minScale: 0.85); or raise maxHeight to 68 mm; or continue on the next page (overflow.continueIn: "next-page"); or cut about 180 characters (page 17, offset 412)The Checks panel shows the same entry in the language of the interface.
#When the text continues
A frame can send what it cannot hold to a page added after its composed page, or to a later page of the book. The rule is the frame's overflow.continueIn:
| Value | Where the content goes on |
|---|---|
'#frame' | Another frame of the same page, as next (see Chaining frames). |
'next-page' | The same frame on a page added after this one, built from the template's overflowTemplate. Without one, the page is the same template laid again with only that frame filled: the other frames take no room (their heights follow their empty content and they leave their groups), so the frame starts near the head of the page, and the decoration and running heads are the template's. |
'template:<id>' | A page of that template. |
'page:<id>' | A frame of the later page fence ::::page{id="<id>"}, past the pages between (see Jumping to a later page). |
{ "id": "tema-cajas", "overflowTemplate": "tema-sigue",
"frames": [
{ "name": "dinero", "style": "caja-azul", "maxHeight": { "value": 40, "unit": "mm" },
"overflow": { "continueIn": "next-page" } } ] },
{ "id": "tema-sigue",
"frames": [ { "name": "dinero", "style": "caja-azul" } ] }Continuing is a step of the reflow ladder: a frame first grows and makes room in its group, and when that is not enough it is cut at its foot, before its pictures or its text are set smaller (unless its fit.preferContinue is false). Its text and pictures stay at full size, the piece ends with the continuation mark, and the rest goes on, broken again at the width of the frame that takes it, from the line where it was cut. Nothing is lost or repeated, and no warning is raised.
- Which frame takes it. On the added page the content goes on in the frame of the same name; when the template has none, in its flow frame; failing that, in its first frame not already taken. A story threaded through frames with
nextgoes on where its chain starts: the rest of the third of three chained columns goes on in the first column of the added page (the frame of the chain head's name, else the flow frame), so a body template that continues into itself fills every column of every page. Several frames of a page that continue to the same template share one added page when that template has a frame for each; otherwise the next one gets a page of its own. A frame of the added page that receives nothing is left empty. - Again and again. A piece that still does not fit goes on again, on the next added page, with the frame's own
overflow.continueInwhen it has one there, or else with the rule that brought it. A composed page adds at most 16 pages one after another; what still does not fit on the last one is cut and reported asframeContinuationLimit. A frame of an added page too small to take any of it reportsframeOverflowinstead of adding pages. - Where the piece is cut. As on the page: a heading stays with its first lines and a list keeps two items on each side (see Chaining frames). When none of the box fits on the page, the whole box goes on, tab and all: the page is not left with a tab and a mark over an empty piece. It takes no room on the page it leaves, and when the answer space under it would not keep its size there, the box goes on whole with it.
- What the pages keep. The frame that is cut gives up its group's room first, so the frames after it keep their size. When the rest continues on the same template laid again, the empty frames right after it in its stack (an answer space under an activity box: frames that receive no content) go with it. On the page they take no room; on the added page they keep their size under the rest of the box, with the decoration anchored to them. The other frames of that added page take no room and their decoration is not drawn, and a stack keeps the place its first frame has in the template, so the rest of the box starts where the stack starts, clear of the page's kicker and running head.
- Ordinary pages. The added pages are pages of the book: they are numbered, carry the running heads of their template (or the section's), take the
variantsof their side, and the{attr.x}of the page fence still reaches their decoration. An overflow template withspread: trueopens on the next verso, with a parity blank before it when needed, and takes the recto after it; a spread whoseoverflowTemplateis a single page continues on single pages. The text after the page fence starts on the page after the last added page. - Ids. A frame of the n-th added page is
cp0:<name>~<n>; the frame that takes the content is named after the frame of the fence's own page that first sent it on (cp0:dinero~1,cp0:dinero~2), so a selection keeps its element whichever frame takes it. Each frame records the frame it continues from or into (continuedFrom,continuesTo), the page'sVDTPage.composed.continuationOfis the index of the fence's own page, and the blocks of the pieces carry the box's id with-cont-<n>, as split callouts do. - Relayout. A composed page whose content continues is laid out afresh, with its added pages, on every build: the page memo keeps only pages whose content stays on them.
#Jumping to a later page
A magazine story that outruns its pages jumps to a page further on, past other stories: «continued on page 47». overflow.continueIn: 'page:<id>' sends the rest to the page fence with that id, wherever it comes later in the chapter:
::::page{template="articulo" sigue="p47"}
…
::::
::::page{template="otra"}
…
::::
::::page{template="saltos" id="p47"}
…
::::{ "name": "cuerpo", "flow": true,
"overflow": { "continueIn": "page:{attr.sigue}",
"mark": "Continued on page {page}", "fromMark": "Continued from page {page}" } }- Which page.
<id>may be{attr.name}, read from the page fence the story is on, so one article template serves every article and the Markdown says where each one jumps. - Which frame. The frame
'page:<id>#<frame>'names; without one, the frame of the sending chain head's name, else the first frame that page's own content leaves empty. The page keeps its own content in its other frames. - After the jump. What that frame cannot hold continues on pages added after the jump page, as
'next-page'does from there; a story that finds no free frame on it goes on there too. - Ids and links. The frames of the jump page keep their own ids (
cp2:resto). The sending frame'scontinuesToand the receiving frame'scontinuedFromlink the pieces, and the sending page's reflow log says «cuerpo continued on page 47». The reflowable EPUB and the tagged PDF read the story in one piece. - A page that does not follow. An id that no later page fence has raises
continueTargetMissing, and the rest goes on on the next page. - In a later chapter file. A magazine kept as one chapter file per article jumps the same way: the page with the
idmay be in a later chapter of the book (since postext 1.41). The sending chapter hands the rest over, and the chapter that has the page sets it in the frame the page leaves free, as it sets a jump inside one file. Footnotes, heading numbers, figure numbers and references in the rest keep the numbers their own chapter gave them, and the marks print the page numbers of the book: «Continued on page 47» names the page as the chapter that has it printed it, whatever the chapters between add. A click on the carried words puts the caret in the Markdown of the chapter they were written in. Several stories sent to one page take its free frames in the order of the chapters. Editing the article lays out the chapter with the page again; editing a chapter in between does not. The tagged PDF reads the rest on its page, after what the page holds itself, and the reflowable EPUB in the chapter that has the page. The rest is set in the typography of the book's text, not in that of a styled section of the chapter that has the page, and an index mark, an anchor or a heading written in it is listed (in the index, the contents and the references, and as a destination in the PDF) on the page where the chapter that has the page sets the words, not on the page where the story starts (since postext 1.42). In the Sandbox canvas, the selection and the caret of the sending chapter's editor are painted over the carried words.
#The continuation mark
overflow.mark sets the words at the end of a cut piece:
| Value | Mark |
|---|---|
| unset | The continuation words of the frame's style (continuesMarker of its callout style), which follow the document's language: «Continued» in English, «Continúa» in Spanish, «Continua» in Catalan, Italian and Portuguese, «À suivre» in French, «Wird fortgesetzt» in German, «接下页» in Chinese, «次ページへ続く» in Japanese, «يتبع» in Arabic. They are the words split tables and split boxes use. |
| a string | Those words: "sigue en la página siguiente". {page} in them is the number of the page where the rest continues, as printed: "Continued on page {page}". |
false | No mark; the piece holds a line more. |
A mark may hold {page}: the printed number of the page where the rest continues, as a magazine writes it (mark: "Continued on page {page}"). It works on an added page ('next-page', 'template:<id>') and on a later page fence the story jumps to ('page:<id>'). The numbers are filled in once the pages are numbered.
The mark is set under the piece's last line, in the box's body face, aligned and slanted as the style's continuesMarkerAlign and continuesMarkerItalic say (right and italic by default). It is pagination furniture: the reflowable EPUB leaves it out, the tagged PDF marks it as an artifact. A frame chained with next on the same page carries no mark.
The piece on the other page opens without the frame's tab and title, as the later parts of a split box do. overflow.fromMark sets words at its head, {page} being the number of the page it comes from: "Continued from page {page}". The receiving frame's own fromMark wins over the sending frame's; with neither set, the piece opens with no words. A style with repeatTitle: true repeats its title there with its continuedSuffix («(cont.)»). Both marks are set in the box's body face, aligned and slanted as the end mark is, and are pagination furniture.
#Reflow log
Each composed page keeps a log of what the layout changed compared with the template as drawn: which frame grew, gave space back or moved, by how much, and which frame set it off. A page whose text fits its template logs nothing. A frame whose height is auto and has no minHeight declares no height of its own: it never grows in the log, and the frames anchored to it never move, however long its text runs (a magazine standfirst with the columns hung below it). Give it the height it is drawn at as minHeight to have both logged. The Cookbook's stress test (C38) compares such frames with the run on the text as written instead.
dinero grew 13.9 mm; gasto moved down 13.9 mm; gasto-fotos moved down 13.9 mm; ahorro moved down 13.9 mm| Event | What it says |
|---|---|
grew | The frame is taller (or, with axis: 'x', wider) than declared: fromMm is the declared size, toMm the size it got. |
resized | The frame is smaller than declared: it gave space to cause. |
moved | The frame's top edge (with axis: 'x', its left edge) moved, in mm from the sheet's edge; cause is the frame whose growth moved it. |
imageScaled | The reflow ladder set the frame's pictures at scale; cause is the frame of the group that needed the room, when it is another. |
textScaled | The reflow ladder set the frame's text at scale. |
continued | The frame's content goes on on a page added after this one: toPage is that page's index in the document and toFrame the id of the frame that takes it there (cp0:dinero~1). In words: «dinero continued on page 9», with the page's printed number. |
overflow | Content did not fit: toMm is the height cut, as in frameOverflow. |
covered | Part of the frame lies under cause, the frame painted over it: areaMm2 is the area hidden, as in frameCovered. In words: «card lies under cutout (25.3 mm²)». Since postext 1.48. |
outside | The frame runs toMm past past: 'trim', 'bleed' or '#name', the frame or group it is anchored inside, as in frameOutsideArea. In words: «note runs 26 mm past card». Since postext 1.48. |
connectorDropped | A connector (cause, its id) left out its end on frame, a box the page does not show: collapsed, optional and empty, a card past the page's items, or a picture point its frame cuts off. A note, not a warning. In words: «connector ramas left out izq (not on the page)». Since postext 1.48. |
Changes under half a millimetre are left out, and each change is rounded once to a tenth of a millimetre, so frames that moved together read the same. Decoration that follows a frame is not listed.
postext check prints one reflow line per composed page that has events, after the warnings; with --json, the report holds a reflow array with one entry per page: pageIndex, pageLabel, template, fenceIndex, chapter, events and lines (the events in words).
From code, the log is VDTPage.composed.log, and each frame keeps the box its template declares in VDTFrame.declaredRect when it differs from rect. composedReflowLog(doc) returns the entries postext check prints, and describeReflowEvent(event) puts one event in words; describeFitStep(step) and describeFrameOverflowProposal(proposal) do the same for a step of the ladder and a proposal. A frame whose text the ladder scaled has VDTFrame.scale below 1: its blocks are laid out in a box 1 / scale as large (frameContentRect(frame)) and frameMatrix(frame) puts them on the sheet; its pictures' scale is VDTFrame.imageScale.
#Spreads
A template with spread: true is one sheet of two facing pages: a band running across the spine, a picture strip from one outer edge to the other, cards on either side. The page fence says so with spread:
::::page{template="linea-tiempo" spread}
# How we measure time
To know when to eat, work or rest, people have always needed to measure time…
:::frame{slot="banda-2"}
With machine clocks
:::
::resource{id="tira-tiempo" slot="tira"}
::::- Where it opens. A spread starts on a verso, the left page of a left-to-right book and the right page of a right-to-left one, and takes the recto after it. When the text before it ends on a verso, the page after that is left blank (a parity blank, as before a comic spread), so the two halves face each other. The text after the closing fence starts on the page after the recto.
- One sheet. The frames are placed on a sheet as wide as both pages. The
contentarea runs from the outer margin of one page to the outer margin of the other, with both inner margins inside it;trimis the two trimmed pages side by side;bleedadds the bleed at the head, the foot and both outer edges, never at the spine. Agriddivides the whole width: six columns put three on each page. In a right-to-left book the sheet is mirrored as its pages are, so the first column stands on the right page. - The gutter.
gutteris a band of that width centred on the spine. A frame withoutcrossGutter: trueis kept off it: a frame reaching across the whole band is cut at the band's edge on the side of its centre, and one whose inner edge falls inside the band moves out of it whole. Anautoheight is measured at the narrower width, and the page's reflow log records the change (resizedormoved, with causegutter). Without agutterthe band is the spine itself, so only frames that ask for it cross the fold. - Across the spine. A frame with
crossGutter: truemay run across. Its text is read once, on the page that holds the frame's centre; the facing page paints its own half of the frame, cut at its sheet, so a band or a picture reads as one piece across the open book. A tagged PDF marks that half as an artifact, the HTML hides it from assistive technology, and selecting or searching the text finds it once. - Decoration is laid once over the whole sheet and cut at the spine the same way: a ground, a card from one page to the other, a running head on the right page. An element anchored to
#framefollows that frame onto the page it lands on. A spread takes novariants, since it has both sides;headerandfooterwork on each of its pages as on any page.
On the canvas, in the Sandbox's spread view and in the Folio the two pages stand side by side. The PDF has two pages, each clipped at its bleed. The fixed-layout EPUB gives them page-spread-left and page-spread-right with rendition:spread-both, so a reader shows them together in either orientation. The reflowable EPUB reads the frames as it reads any composed page, in Markdown order.
#spreadMismatch
Cause. The page fence and its template disagree: the fence has spread and the template is a single page, or the template is a spread (by its own spread: true or through extends) and the fence lacks the flag. The template decides: a spread template is laid over two facing pages, any other on one page. The warning gives the template, the fence's flag (fence) and the template's (templateSpread), and points at the spread attribute, or at the template's name when the fence has none.
Fix. Make the fence say what the template is: write spread on the fence of a spread template, remove it from the fence of a single-page one, or choose another template.
#Migrating a book with text in its styles
A book made before composed pages may hold the text of its pages in heading styles: a hidden heading on each page whose running head places every text where the printed page had it. The Text held in the configuration check lists it. In the Sandbox, Move the text to the Markdown in the Checks panel turns each page design into a page template whose frames stand where the texts stood, and each page into a page fence with its text in :::frame slots; it shows every page before and after, and can be undone. See Moving the text to the Markdown. From code, moveTextToMarkdown({ config, chapters, metadata }, options) does the same and returns the new configuration, the chapters and a report.
With labelsOnPictures: true (since postext 1.38), the words a design placed on a picture become the picture's labels instead of frames: a text of one line and at most four words, no larger than three quarters of the body text (labelsOnPictures: { maxFontSize } sets another limit), whose box lies inside a picture of the same design. The picture moves from the decoration into a frame at the box where it was drawn, holding a :::figure with one ::label line per text, and each text becomes an anchor of the picture's resource at the point where the design set it (its first baseline, the side its alignment names, its box's width), with a label style for its look. Pass the book's resources in the input: the result returns them with the anchors (result.resources), and a bitmap smaller than the box the design stretched it over gets the resolution that sets it at that width. A picture shown on several pages shares its anchors. The report's labels counts the pictures, labels, anchors and label styles. The Sandbox's dialog offers it as an option, off by default, when the book has words to turn into labels. When the design painted decoration over the picture (a tag across the map) and none under it, the picture's frame goes on layer -1, below the decoration, so the tag stays over the map (since postext 1.40). With decoration under the picture as well, or over one of its labels, a single slot cannot hold both orders: the frame stays on layer 0, and the page is reported as one that may look different (overPicture).
#From code
composedPages(blocks) reads the parsed blocks of a chapter (parseMarkdownWithIssues(markdown).blocks) and returns one node per page fence, in order: its template, spread, attrs with the source range of each value (attrSources), its fenceIndex (the ordinal of the fence in the chapter, the same in every language), slots (the indices of the blocks of each slot, in Markdown order), unassigned (the blocks with no slot) and the source range of the whole page. A block carries the slot it names in ContentBlock.slot, with the source range of the value; a figure is a resourceBlock whose figure holds its attributes and labels, each label with its text, its inline spans and a source map back to the Markdown. checkComposedSlots(pages, config) returns the three slot warnings for those pages.
After layout, a composed page's VDTPage.composed records its template, the variant applied, the page fence's attributes and, for each frame, its id (cp0:dinero: the page fence's ordinal and the frame's name, the same in every language), its box, layer, turn, the height of content that did not fit (overflowPx), the frame it continues from or into, its config path (/pageTemplates/0/frames/2) and the ids of its blocks. Those blocks are ordinary callout blocks in page.floats and doc.blocks, with their source ranges, so a click in an upright frame of the Sandbox preview lands on its Markdown. composedPaintOrder(page) gives the order a renderer paints the frames and the decoration in, and frameMatrix(frame) the turn of a frame.
#Source map
Everything a composed page paints knows where it was written, so an editor can go from a point of the page to the Markdown or the configuration, and from a range of the Markdown to what it became on the page.
sourceAt(doc, pageIndex, x, y) takes a point of a laid-out page, in page pixels from the sheet's top-left corner, and returns what is there, innermost first, each element followed by the ones that hold it. A glyph of a box comes with its line, its paragraph, its frame, the frame's groups and the template; a word of the decoration comes with its design element, the decoration and the template. Each element has a level, a stable id, a source, and, for most, its rect on the page (upright, before a turned frame's rotate).
On a right-to-left or vertical page the frames are laid in the page's flow frame, mirrored or turned a quarter on the sheet, while the decoration and the running heads stay on the sheet. sourceAt still takes sheet points and maps them for the frames. An element whose rect is in the flow frame comes with flow: true, in sourceAt, elementsForSource and findElement alike; flowRectToPage(page, rect) gives its box on the sheet, and flowToPage(page, x, y) a point of it. Up to postext 1.38 a sheet point on a frame of such a page found only the template.
| Source | Fields | Given for |
|---|---|---|
markdown | start, end (offsets in the chapter file, front matter counted), file | a glyph (one character; a whole chip, reference or formula when the glyph is one), a line, a paragraph or list item, a box round it |
config | path, a JSON pointer | a frame (/pageTemplates/0/frames/2), a group, the template, a design element of the decoration or the running heads (/footer/elements/0) and its slot |
attr | name, start, end, file | text an element shows through {attr.x} (the value in the page fence), a frame's tab and title (the label and title of its :::frame fence), a picture chosen by {attr.x} |
resource | resourceId, anchor | a picture in a frame or in the decoration; a label carries its anchor as resourceId#anchorId |
The levels, innermost first: text, attr, label, resource, line, block, box, frame, group, design, slot, template. A frame and the template also carry content, the range of the Markdown they hold: the frame's slot content, the whole page fence. file is the name the host passes in the options ({ file: 'tema-1.md' }, or a function of the page index for a document stitched from several chapters).
import { buildDocument, sourceAt, elementsForSource, findElement } from 'postext';
const doc = buildDocument({ markdown, resources }, config);
const chain = sourceAt(doc, 0, 640, 1180, { file: 'tema-1.md' });
// [ { level: 'text', id: 'cp0:dinero-c0@12', source: { kind: 'markdown', start: 677, end: 678, file: 'tema-1.md' } },
// { level: 'line', … }, { level: 'block', id: 'cp0:dinero-c0', … },
// { level: 'frame', id: 'cp0:dinero', source: { kind: 'config', path: '/pageTemplates/0/frames/2' }, content: { start: 665, end: 942 } },
// { level: 'template', id: 'cp0', source: { kind: 'config', path: '/pageTemplates/0' } } ]
elementsForSource(doc, 677, 690); // lines, blocks, frames, pages and design text the range touches
findElement(doc, 'cp0:dinero'); // the same frame after a relayout, with its rectelementsForSource(doc, start, end) goes the other way and returns { pageIndex, element } for every line, block, frame, composed page and design text the range touches. A line set past its frame's foot comes with clipped: true: it is cut on the page and kept in the source map. On a spread, the half of a frame that crosses the spine and is read on the facing page answers with the ids of the blocks it shows and facing: true, in sourceAt and in elementsForSource. There elementsForSource gives each page the frame with the part of its box that page paints as its rect, so a band that starts near the spine has a point to click on both pages. A figure label answers at level label, with its id and its anchor, wherever it is drawn on the picture.
Stable ids. A composed page is cp<n>, n the ordinal of its page fence in the chapter; a frame is cp<n>:<frame> (with ~<k> for the k-th piece of its content that continues on a later page), its blocks cp<n>:<frame>-c0, -c1…, a group cp<n>:group:<name>, an element of the decoration or the running heads cp<n>:decoration:<id>, cp<n>:header:<id>, cp<n>:footer:<id>, and a label of a figure cp<n>:<slot>:label:<anchor>. None of them depends on positions or on the words, so an id is the same after any relayout and in every language of the chapter: a selection survives an edit, and the same frame can be found in the translation. findElement(doc, id) finds the element again.
Contents entries. A row of :::toc carries in tocEntry.headingSource the offset of the heading it lists in its chapter's Markdown body (front matter not counted, as outlines count); sourceAt gives it as heading on the row's block.
Relayout of one page. The layout of each composed page is kept by what it reads: the template, the Markdown of the page, the styles and fonts, the language, the side of the sheet and its geometry. A later build that meets the same page (the next pass of the layout, an edit elsewhere in the chapter, the chapter paginated again in the same worker) takes it as it was. An edit inside a page, or a change of an attribute of its fence, sets that page alone; a change of the template sets every page that uses it. A page holding footnotes, references, citations or a contents listing is set afresh every time, since what it prints depends on the rest of the book. A spread is laid out afresh every time too: its two pages are one sheet. VDTComposedPage.layoutKey is the key of a page's frames; composedPagePaintKey(page) adds what is laid round them (running heads, decoration, page number), so a host can keep the pixels it painted while the key stays the same. The Sandbox canvas does: an edit on one page repaints that page.
#Comic pages
A comic page (:::page{split}) is a composed page whose frames its split generates: one per panel, with stable ids cm<n>:<name>, a polygon for a slanted cell, a callout style through box, and Markdown poured into a text panel. See Comics › Comic pages and composed pages.
