page

package
v0.3.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package page lays out the page of a workbook: where each item of a task on a workbook stands, its number, the texts of its line and its boxes, in whole units of the page, from the items alone, by the numbers and the table of widths of format/page.yaml (R51 spec). A box so stands where it stands on every device, whatever its fonts: the canvas fits each text to the width the layout gives it (R34 canvas, R35 canvas).

Lay gives the Layout of a task's items, each a line of Pieces — a text, or a box —, or NoRoom, the item at whose row the page has no room. TextWidth gives the width of a text as the layout sets it on one line, and Fits whether a value written in a box is no wider than the box, Numbers' BoxWidth. The test vectors of the page, format/vectors/pages/, pin every place, and internal/vectors passes them all.

The check of a module holds task.workbook-page by it, and lesson.workbook-page, whose values fit their boxes by Fits; canvas lays its pages out by the same numbers, from the npm package of spec. The package holds a copy of page.yaml, byte for byte that of spec.Format at the tag go.mod requires, and does not import spec itself: a consumer of the library carries the one file, not every file of the format (R52).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fits

func Fits(value string) bool

Fits says whether a value written in a box fits the box: as a text of the line, it is no wider than the numbers' BoxWidth, as lesson.workbook-page holds the value of each box of a worked example.

func MostItems

func MostItems() int

MostItems gives the most items that a page holds, most_items of page.yaml: the item after them has no room.

func Numbers

func Numbers() formatv0.PageNumbers

Numbers gives the numbers of the layout, numbers of page.yaml, in units of the page: the type size, the width and the height of a box, and the rest.

func TextWidth

func TextWidth(text string) int64

TextWidth gives the width, in units of the page, of a text as the layout sets it on one line, as one piece of a line: its words, cut at the runs of the white space that breaks, joined by single spaces, size × (the sum of their widths + the space × the spaces between them) ÷ 100, rounded up. A text of white space alone, or none, is 0 wide.

Types

type Item

type Item struct {
	Number Text
	Line   []Part
}

Item is an item on the page: its number, n., right in the column of the numbers on the baseline of its first line, and the texts and boxes of its line, in the order they are read.

func (Item) PageItem

func (i Item) PageItem() formatv0.PageItem

PageItem gives the item as a vector of the page holds it.

type Layout

type Layout struct {
	Items  []Item
	Bottom int64
}

Layout is the page of a task's items: each item on it, in the task's order, and Bottom, the bottom of the last row. A task of no items has none, and its bottom is the margin, where the first row would start.

func Lay

func Lay(items [][]Piece) (Layout, error)

Lay lays out the items of a task on a workbook, each its line of pieces, on the page by page.yaml. Rows start at the margin, each the gap of items below the one before: two short items side by side, in the two columns, and a short item before a long one, or before none, alone at the left; a long item across the page, its lines filled greedily, run by run. When a row would pass the lowest unit, or an item comes after the most_items of page.yaml, it gives a *NoRoom with the first item of that row, and nothing ever shrinks.

type NoRoom

type NoRoom struct {
	Item int
}

NoRoom is what Lay gives when the page has no room: Item, counted from 0, is the first item of the row that has none, at which the page is refused (task.workbook-page) — or the first item after the most_items of page.yaml, which has none either.

func (*NoRoom) Error

func (e *NoRoom) Error() string

type Part

type Part struct {
	Box      bool
	Text     string
	Left     int64
	Baseline int64
	Width    int64
	Top      int64
	Height   int64
}

Part is a part of an item's line on the page: a text, as a Text, or, when Box is set, a box, from Left and Top, Width wide and Height high. The fields of the other kind are 0, and a box has no Text.

func (Part) PagePart

func (p Part) PagePart() formatv0.PagePart

PagePart gives the part as a vector of the page holds it: a text with its left, its baseline and its width, and a box with its left, top, width and height.

type Piece

type Piece struct {
	Text string
	Box  bool
}

Piece is a piece of an item's line, as the open view holds it: a piece of text, Text, or, when Box is set, a box, an answer slot, whose Text is nothing.

type Text

type Text struct {
	Text     string
	Left     int64
	Baseline int64
	Width    int64
}

Text is a text set on the page: Text, its words joined by single spaces, from Left, on its alphabetic baseline, Baseline, fitted to Width. Every number is in units of the page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL