@astl/engine 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,8 @@
42
42
  "BADGE_TOO_LONG": "This badge holds more than {max} characters: keep a badge to a number or a word or two, and write longer text beside it.",
43
43
  "BOX_NESTED": "A frame cannot stand inside another frame: put it after the frame, or use a heading inside it.",
44
44
  "TASK_NESTED": "A task cannot stand inside another task: put it after the task, or make it a sub-task (astl-subtask).",
45
+ "TABLE_INVALID": "A table holds a caption (<caption>, optional, first), then rows (<tr>) in a head (<thead>) and bodies (<tbody>), and each row cells (<th>, <td>) that cover the same columns as the other rows; a span (colspan, rowspan) stays within the rows of its part.",
46
+ "TABLE_TOO_LARGE": "A table has at most {maxColumns} columns and {maxRows} rows; this one has {columns} columns and {rows} rows.",
45
47
  "HELP_UNGRADED": "Element <{tag}> works only inside a graded interaction or on a page with one. Move it there: for now it is left out.",
46
48
  "HELP_EMPTY": "Element <{tag}> is empty, so it is left out. Write its text or remove it.",
47
49
  "PAGE_HELP_UNCHECKED": "Page {page}{titled, select, yes { (“{title}”)} other {}} has help for students but no Check of its own: turn on “Check this page”. Until then the player adds that Check by itself.",
@@ -42,6 +42,8 @@
42
42
  "BADGE_TOO_LONG": "Ten znaczek ma więcej niż {max} znaków: w znaczku zostaw liczbę albo słowo lub dwa, a dłuższy tekst napisz obok.",
43
43
  "BOX_NESTED": "Ramki nie można wstawić do innej ramki: postaw ją za ramką albo użyj w niej nagłówka.",
44
44
  "TASK_NESTED": "Zadania nie można wstawić do innego zadania: postaw je za zadaniem albo zrób z niego podpunkt (astl-subtask).",
45
+ "TABLE_INVALID": "Tabela zawiera podpis (<caption>, opcjonalny, na początku), potem wiersze (<tr>) w nagłówku (<thead>) i treści (<tbody>), a każdy wiersz komórki (<th>, <td>) zajmujące te same kolumny co inne wiersze; scalenie (colspan, rowspan) nie wychodzi poza wiersze swojej części.",
46
+ "TABLE_TOO_LARGE": "Tabela ma najwyżej {maxColumns} kolumn i {maxRows} wierszy; ta ma kolumn: {columns}, wierszy: {rows}.",
45
47
  "HELP_UNGRADED": "Element <{tag}> działa tylko w ocenianym zadaniu albo na stronie z takim zadaniem. Przenieś go tam: na razie jest pominięty.",
46
48
  "HELP_EMPTY": "Element <{tag}> jest pusty, więc jest pominięty. Wpisz jego treść albo go usuń.",
47
49
  "PAGE_HELP_UNCHECKED": "Strona {page}{titled, select, yes { („{title}”)} other {}} ma pomoc dla uczniów, ale nie ma własnego sprawdzania: włącz „Sprawdź tę stronę”. Do tego czasu odtwarzacz sam dodaje to sprawdzanie.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astl/engine",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Isomorphic Astrolabe engine: parse, sanitise, validate, compile (view + answer key + metadata) and grade.",
5
5
  "keywords": [
6
6
  "astrolabe",
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@astl/core": "0.6.0",
51
+ "@astl/core": "0.7.0",
52
52
  "parse5": "8.0.1"
53
53
  }
54
54
  }
package/src/analyse.ts CHANGED
@@ -64,6 +64,8 @@ import {
64
64
  MAX_COLUMNS,
65
65
  MAX_NESTING_DEPTH,
66
66
  MAX_SOURCE_LENGTH,
67
+ MAX_TABLE_COLUMNS,
68
+ MAX_TABLE_ROWS,
67
69
  MAX_TASK_LABELS,
68
70
  MAX_TASK_LEVEL,
69
71
  MIN_COLUMNS,
@@ -83,6 +85,15 @@ import {
83
85
  SUBTASK_LEVELS,
84
86
  SUBTASK_TAG,
85
87
  SUPPORTED_FORMATS,
88
+ TABLE_BODY_TAG,
89
+ TABLE_CAPTION_TAG,
90
+ TABLE_CELL_TAG,
91
+ TABLE_HEAD_TAG,
92
+ TABLE_HEADER_CELL_TAG,
93
+ TABLE_ROW_TAG,
94
+ TABLE_SCOPES,
95
+ TABLE_TAG,
96
+ TABLE_TAGS,
86
97
  TAG_ATTRIBUTES,
87
98
  TASK_LABEL_ICONS,
88
99
  TASK_LABEL_TAG,
@@ -112,13 +123,16 @@ import { mostAttributes } from './limits.js';
112
123
  import { round6 } from './round.js';
113
124
 
114
125
  /**
115
- * Where inline components may sit: text-holding blocks, captions and inline formatting, never inside a link (and a
116
- * rule, a line break or a picture holds nothing).
126
+ * Where inline components may sit: text-holding blocks, captions, table cells and inline formatting, never inside a
127
+ * link (and a rule, a line break or a picture holds nothing).
117
128
  */
118
129
  const TEXT_PARENTS: ReadonlySet<string> = new Set([
119
130
  ...[...BLOCK_TAGS].filter((t) => t !== 'ul' && t !== 'ol' && t !== RULE_TAG),
120
131
  ...[...INLINE_TAGS].filter((t) => t !== 'a' && t !== 'br' && t !== 'img'),
121
132
  CAPTION_TAG,
133
+ TABLE_CAPTION_TAG,
134
+ TABLE_HEADER_CELL_TAG,
135
+ TABLE_CELL_TAG,
122
136
  ]);
123
137
 
124
138
  const DIRECTIONS: ReadonlySet<string> = new Set(['ltr', 'rtl', 'auto']);
@@ -141,6 +155,7 @@ const RULE_TARGETS: ReadonlySet<string> = new Set([
141
155
  INSTRUCTION_TAG,
142
156
  TASK_LABEL_TAG,
143
157
  SUBTASK_TAG,
158
+ ...TABLE_TAGS,
144
159
  ]);
145
160
  /** The contrast WCAG asks of normal text (AA); large text may have less, and then the warning is only stricter. */
146
161
  const MIN_CONTRAST = 4.5;
@@ -294,6 +309,63 @@ interface Where {
294
309
 
295
310
  type Visitor = (el: ElementNode, place: Place) => Node[] | null;
296
311
 
312
+ /** A cell's `colspan` or `rowspan`: 1 when absent, 0 when it is no whole number from 1 to `max`. */
313
+ function tableSpan(value: string | undefined, max: number): number {
314
+ if (value === undefined) return 1;
315
+ const n = parseIntegerValue(value);
316
+ return n !== null && n >= 1 && n <= max ? n : 0;
317
+ }
318
+
319
+ /**
320
+ * The columns a table's rows cover, row by row as HTML lays them out: a cell takes the first column no span from a row
321
+ * above holds, and as many as its `colspan`; its `rowspan` holds them in the rows below, within its part (a head, a
322
+ * body, the rows standing directly in the table).
323
+ */
324
+ class TableGrid {
325
+ rows = 0;
326
+ /** The table's columns: the most any row covers. */
327
+ columns = 0;
328
+ /** What the first row covered: every other row must cover as much. */
329
+ #width: number | null = null;
330
+ /** Per column, how many more rows a span from above holds it. */
331
+ #held: number[] = [];
332
+
333
+ /** A new part: spans never cross into it. */
334
+ start(): void {
335
+ this.#held = [];
336
+ }
337
+
338
+ /** The end of a part: whether a span reached past its last row. */
339
+ end(): boolean {
340
+ const past = this.#held.some((n) => n > 0);
341
+ this.#held = [];
342
+ return past;
343
+ }
344
+
345
+ /** One row of cells (`[colspan, rowspan]`, 0 for an invalid span, counted as 1): whether it fits the table. */
346
+ row(cells: readonly (readonly [number, number])[]): boolean {
347
+ this.rows++;
348
+ const above = this.#held.map((n) => n > 0);
349
+ const held = this.#held.map((n) => Math.max(0, n - 1));
350
+ let fits = true;
351
+ let at = 0;
352
+ for (const [colspan, rowspan] of cells) {
353
+ while (above[at]) at++;
354
+ for (let column = at; column < at + Math.max(1, colspan); column++) {
355
+ // A cell running into a column a span from above holds.
356
+ if (above[column]) fits = false;
357
+ held[column] = Math.max(held[column] ?? 0, Math.max(1, rowspan) - 1);
358
+ }
359
+ at += Math.max(1, colspan);
360
+ }
361
+ this.#held = Array.from({ length: Math.max(held.length, at) }, (_, i) => held[i] ?? 0);
362
+ const width = Math.max(at, above.lastIndexOf(true) + 1);
363
+ this.columns = Math.max(this.columns, width);
364
+ this.#width ??= width;
365
+ return fits && width === this.#width;
366
+ }
367
+ }
368
+
297
369
  function own(attrs: Readonly<Record<string, string>>, name: string): string | undefined {
298
370
  return Object.hasOwn(attrs, name) ? attrs[name] : undefined;
299
371
  }
@@ -639,7 +711,8 @@ class Analyser {
639
711
  const record = this.components.get(node);
640
712
  return {
641
713
  id: record?.sourceId ?? null,
642
- graded: isCheckable(definition.manifest),
714
+ // An example is answered already: nothing for a Check.
715
+ graded: isCheckable(definition.manifest) && definition.example?.(node) !== true,
643
716
  block: definition.manifest.display === 'block',
644
717
  };
645
718
  },
@@ -919,6 +992,16 @@ class Analyser {
919
992
  }
920
993
  // A figure is a block: in a prompt or an option it is unwrapped like the other blocks, below.
921
994
  if (tag === FIGURE_TAG && scope.mode === 'flow') return [this.visitFigure(el, scope, place, where)];
995
+ if (tag === TABLE_TAG) {
996
+ return scope.mode === 'flow'
997
+ ? [this.visitTable(el, scope, place, where)]
998
+ : this.unwrapTable(el, scope, place, where);
999
+ }
1000
+ // A part of a table out of its table (a cell outside a row): its content stays, to be validated.
1001
+ if (TABLE_TAGS.has(tag)) {
1002
+ this.add(EngineIssue.TABLE_INVALID, {}, where);
1003
+ return this.visitNodes(el, scope, place.path);
1004
+ }
922
1005
  if (tag.includes('-')) {
923
1006
  const host = scope.host;
924
1007
  const spec = host?.manifest.children.find((c) => c.tag === tag);
@@ -1314,6 +1397,13 @@ class Analyser {
1314
1397
  this.invalid(el.tag, name, value, 'integer', [], where);
1315
1398
  } else if ((name === 'width' || name === 'height') && !((parseIntegerValue(value) ?? 0) > 0)) {
1316
1399
  this.invalid(el.tag, name, value, 'integer', [], where);
1400
+ } else if (
1401
+ (name === 'colspan' || name === 'rowspan') &&
1402
+ tableSpan(value, name === 'colspan' ? MAX_TABLE_COLUMNS : MAX_TABLE_ROWS) === 0
1403
+ ) {
1404
+ this.invalid(el.tag, name, value, 'integer', [], where);
1405
+ } else if (name === 'scope' && !(TABLE_SCOPES as readonly string[]).includes(value)) {
1406
+ this.invalid(el.tag, name, value, 'enum', TABLE_SCOPES, where);
1317
1407
  } else {
1318
1408
  attrs[name] = value;
1319
1409
  }
@@ -1333,18 +1423,7 @@ class Analyser {
1333
1423
  * and at most one caption. A caption holds rich inline text, which may hold inline components like any text.
1334
1424
  */
1335
1425
  private visitFigure(el: ElementNode, scope: Scope, place: Place, where: Where): ElementNode {
1336
- if (
1337
- scope.parent !== PAGE_TAG &&
1338
- scope.parent !== DOC_TAG &&
1339
- scope.parent !== COLUMN_TAG &&
1340
- scope.parent !== BOX_TAG &&
1341
- scope.parent !== TASK_TAG &&
1342
- scope.parent !== SUBTASK_TAG &&
1343
- scope.parent !== scope.host?.manifest.tag &&
1344
- !HELP_TAGS.has(scope.parent)
1345
- ) {
1346
- this.add(EngineIssue.PLACEMENT_INVALID, { tag: el.tag }, where);
1347
- }
1426
+ if (!this.blockPlace(scope)) this.add(EngineIssue.PLACEMENT_INVALID, { tag: el.tag }, where);
1348
1427
  const attrs = this.richAttributes(el, where, scope);
1349
1428
  const inner: Scope = { ...scope, ...this.below(attrs, scope), parent: FIGURE_TAG };
1350
1429
  let pictures = 0;
@@ -1365,6 +1444,150 @@ class Analyser {
1365
1444
  return element(FIGURE_TAG, attrs, children);
1366
1445
  }
1367
1446
 
1447
+ /** Where a figure or a table may stand: directly in a page, the document, a column, a frame, a task, a rich block or help. */
1448
+ private blockPlace(scope: Scope): boolean {
1449
+ return (
1450
+ scope.parent === PAGE_TAG ||
1451
+ scope.parent === DOC_TAG ||
1452
+ scope.parent === COLUMN_TAG ||
1453
+ scope.parent === BOX_TAG ||
1454
+ scope.parent === TASK_TAG ||
1455
+ scope.parent === SUBTASK_TAG ||
1456
+ scope.parent === scope.host?.manifest.tag ||
1457
+ HELP_TAGS.has(scope.parent)
1458
+ );
1459
+ }
1460
+
1461
+ /**
1462
+ * A table, where a figure may stand. Its caption (first, once) holds rich inline text; then a head (once, before the
1463
+ * bodies) and bodies of rows, or rows directly in it (one body until the next part); a row holds header and data
1464
+ * cells, whose content is rich inline text with inline components in it. A part out of its place, text between
1465
+ * rows or cells, rows that cover different columns, a span past the rows of its part or no rows at all are
1466
+ * TABLE_INVALID, reported at the part; more than MAX_TABLE_COLUMNS columns or MAX_TABLE_ROWS rows TABLE_TOO_LARGE.
1467
+ */
1468
+ private visitTable(el: ElementNode, scope: Scope, place: Place, where: Where): ElementNode {
1469
+ if (!this.blockPlace(scope)) this.add(EngineIssue.PLACEMENT_INVALID, { tag: el.tag }, where);
1470
+ const attrs = this.richAttributes(el, where, scope);
1471
+ const inner: Scope = { ...scope, ...this.below(attrs, scope), parent: TABLE_TAG };
1472
+ const grid = new TableGrid();
1473
+ // What came last: the order is caption, head, bodies (and rows of their own).
1474
+ const seen: { last: 'start' | 'caption' | 'head' | 'body' | 'rows' } = { last: 'start' };
1475
+ const children = this.visitNodes(el, inner, place.path, (child, childPlace) => {
1476
+ const at = this.where(inner, childPlace, child.tag);
1477
+ if (child.tag === TABLE_CAPTION_TAG && seen.last === 'start') {
1478
+ seen.last = 'caption';
1479
+ const caption = this.richAttributes(child, at, inner);
1480
+ const text: Scope = {
1481
+ ...inner,
1482
+ ...this.below(caption, inner),
1483
+ parent: TABLE_CAPTION_TAG,
1484
+ mode: 'inline',
1485
+ };
1486
+ return [element(TABLE_CAPTION_TAG, caption, this.visitNodes(child, text, childPlace.path))];
1487
+ }
1488
+ if (child.tag === TABLE_HEAD_TAG && (seen.last === 'start' || seen.last === 'caption')) {
1489
+ seen.last = 'head';
1490
+ return [this.visitTableSection(child, inner, childPlace, at, grid)];
1491
+ }
1492
+ if (child.tag === TABLE_BODY_TAG) {
1493
+ if (seen.last === 'rows') this.endTableSection(grid, where);
1494
+ seen.last = 'body';
1495
+ return [this.visitTableSection(child, inner, childPlace, at, grid)];
1496
+ }
1497
+ if (child.tag === TABLE_ROW_TAG) {
1498
+ if (seen.last !== 'rows') grid.start();
1499
+ seen.last = 'rows';
1500
+ return [this.visitTableRow(child, inner, childPlace, at, grid)];
1501
+ }
1502
+ this.add(EngineIssue.TABLE_INVALID, {}, at);
1503
+ return [];
1504
+ });
1505
+ if (seen.last === 'rows') this.endTableSection(grid, where);
1506
+ if (children.some((n) => n.type === 'text' && !isHtmlWhitespace(n.value)) || grid.rows === 0) {
1507
+ this.add(EngineIssue.TABLE_INVALID, {}, where);
1508
+ }
1509
+ if (grid.columns > MAX_TABLE_COLUMNS || grid.rows > MAX_TABLE_ROWS) {
1510
+ const params = {
1511
+ columns: grid.columns,
1512
+ rows: grid.rows,
1513
+ maxColumns: MAX_TABLE_COLUMNS,
1514
+ maxRows: MAX_TABLE_ROWS,
1515
+ };
1516
+ this.add(EngineIssue.TABLE_TOO_LARGE, params, where);
1517
+ }
1518
+ return element(TABLE_TAG, attrs, children);
1519
+ }
1520
+
1521
+ /** A head or a body: rows only, its spans ending with it. */
1522
+ private visitTableSection(
1523
+ el: ElementNode,
1524
+ scope: Scope,
1525
+ place: Place,
1526
+ where: Where,
1527
+ grid: TableGrid,
1528
+ ): ElementNode {
1529
+ const attrs = this.richAttributes(el, where, scope);
1530
+ const inner: Scope = { ...scope, ...this.below(attrs, scope), parent: el.tag };
1531
+ grid.start();
1532
+ const children = this.visitNodes(el, inner, place.path, (child, childPlace) => {
1533
+ const at = this.where(inner, childPlace, child.tag);
1534
+ if (child.tag === TABLE_ROW_TAG) return [this.visitTableRow(child, inner, childPlace, at, grid)];
1535
+ this.add(EngineIssue.TABLE_INVALID, {}, at);
1536
+ return [];
1537
+ });
1538
+ if (children.some((n) => n.type === 'text' && !isHtmlWhitespace(n.value))) {
1539
+ this.add(EngineIssue.TABLE_INVALID, {}, where);
1540
+ }
1541
+ this.endTableSection(grid, where);
1542
+ return element(el.tag, attrs, children);
1543
+ }
1544
+
1545
+ /** A span that reaches past the last row of its part. */
1546
+ private endTableSection(grid: TableGrid, where: Where): void {
1547
+ if (grid.end()) this.add(EngineIssue.TABLE_INVALID, {}, where);
1548
+ }
1549
+
1550
+ /** A row: cells only, covering the columns of the rows before it. */
1551
+ private visitTableRow(
1552
+ el: ElementNode,
1553
+ scope: Scope,
1554
+ place: Place,
1555
+ where: Where,
1556
+ grid: TableGrid,
1557
+ ): ElementNode {
1558
+ const attrs = this.richAttributes(el, where, scope);
1559
+ const inner: Scope = { ...scope, ...this.below(attrs, scope), parent: TABLE_ROW_TAG };
1560
+ const spans: (readonly [columns: number, rows: number])[] = [];
1561
+ const children = this.visitNodes(el, inner, place.path, (child, childPlace) => {
1562
+ const at = this.where(inner, childPlace, child.tag);
1563
+ if (child.tag !== TABLE_HEADER_CELL_TAG && child.tag !== TABLE_CELL_TAG) {
1564
+ this.add(EngineIssue.TABLE_INVALID, {}, at);
1565
+ return [];
1566
+ }
1567
+ const cell = this.richAttributes(child, at, inner);
1568
+ spans.push([tableSpan(cell.colspan, MAX_TABLE_COLUMNS), tableSpan(cell.rowspan, MAX_TABLE_ROWS)]);
1569
+ const text: Scope = { ...inner, ...this.below(cell, inner), parent: child.tag, mode: 'inline' };
1570
+ return [element(child.tag, cell, this.visitNodes(child, text, childPlace.path))];
1571
+ });
1572
+ if (children.some((n) => n.type === 'text' && !isHtmlWhitespace(n.value)) || !grid.row(spans)) {
1573
+ this.add(EngineIssue.TABLE_INVALID, {}, where);
1574
+ }
1575
+ return element(TABLE_ROW_TAG, attrs, children);
1576
+ }
1577
+
1578
+ /**
1579
+ * A table in a prompt, an option or a card, where blocks are unwrapped: its parts go, the text of its caption and
1580
+ * cells stays, a space between them.
1581
+ */
1582
+ private unwrapTable(el: ElementNode, scope: Scope, place: Place, where: Where): Node[] {
1583
+ this.add(EngineIssue.ELEMENT_REMOVED, { tag: el.tag }, where, 'warning');
1584
+ const unwrap: Visitor = (child, childPlace) =>
1585
+ TABLE_TAGS.has(child.tag)
1586
+ ? [{ type: 'text', value: ' ' }, ...this.visitNodes(child, scope, childPlace.path, unwrap)]
1587
+ : null;
1588
+ return this.visitNodes(el, scope, place.path, unwrap);
1589
+ }
1590
+
1368
1591
  private visitPage(el: ElementNode, index: number, place: Place, base: Scope): ElementNode {
1369
1592
  const id = own(el.attrs, 'id');
1370
1593
  const where: Where = {
@@ -1415,7 +1638,7 @@ class Analyser {
1415
1638
  const id = own(raw.attrs, 'id');
1416
1639
  const where: Where = { order: place.order, page: scope.page, element: id ?? null, tag, path: place.path };
1417
1640
  this.componentCount++;
1418
- if (manifest.graded) this.gradedPages.add(scope.pageIndex);
1641
+ if (manifest.graded && definition.example?.(raw) !== true) this.gradedPages.add(scope.pageIndex);
1419
1642
  if (!placementAllowed(manifest.display, scope)) this.add(EngineIssue.PLACEMENT_INVALID, { tag }, where);
1420
1643
 
1421
1644
  const el = this.upgrade(raw, definition, where);
package/src/compile.ts CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  type ScoringGroup,
32
32
  type SlotKind,
33
33
  STYLE_TEMPLATE_ATTRIBUTE,
34
+ TABLE_TAG,
34
35
  TASK_TAG,
35
36
  type UrlPolicy,
36
37
  } from '@astl/core';
@@ -205,8 +206,8 @@ export async function compileDocument(doc: DocRecord, setup: CompileSetup): Prom
205
206
  const open: string[] = [];
206
207
  for (const rec of doc.components.values()) {
207
208
  const manifest = rec.definition.manifest;
208
- // Ungraded types without slot kinds (flash cards, media) have nothing to answer.
209
- if (manifest.slotKinds.length === 0) continue;
209
+ // Ungraded types without slot kinds (flash cards, media) have nothing to answer; an example is answered already.
210
+ if (manifest.slotKinds.length === 0 || rec.definition.example?.(rec.element)) continue;
210
211
  const ctx = contextOf(rec);
211
212
  const page = pageIds[rec.page] as string;
212
213
  const groupId = ctx.opaque();
@@ -299,7 +300,7 @@ export async function compileDocument(doc: DocRecord, setup: CompileSetup): Prom
299
300
  }
300
301
 
301
302
  const isBlock = (node: Node): boolean =>
302
- isElement(node) && (BLOCK_TAGS.has(node.tag) || node.tag === FIGURE_TAG);
303
+ isElement(node) && (BLOCK_TAGS.has(node.tag) || node.tag === FIGURE_TAG || node.tag === TABLE_TAG);
303
304
 
304
305
  /**
305
306
  * The HTML of help content as a browser rebuilds it, like the view's (see the end of `compileDocument`). Blocks lose
package/src/guard.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  isOpaqueId,
18
18
  LANGUAGE_TAG_PATTERN,
19
19
  type Node,
20
+ TABLE_TAGS,
20
21
  TAG_ATTRIBUTES,
21
22
  URL_ATTRIBUTES,
22
23
  type UrlPolicy,
@@ -141,7 +142,11 @@ function contentProblem(
141
142
  continue;
142
143
  }
143
144
  const inline = INLINE_TAGS.has(node.tag) || node.tag === BADGE_TAG;
144
- const block = BLOCK_TAGS.has(node.tag) || node.tag === FIGURE_TAG || node.tag === CAPTION_TAG;
145
+ const block =
146
+ BLOCK_TAGS.has(node.tag) ||
147
+ node.tag === FIGURE_TAG ||
148
+ node.tag === CAPTION_TAG ||
149
+ TABLE_TAGS.has(node.tag);
145
150
  if (!inline && !(blocks && block)) return `writes <${node.tag}>`;
146
151
  if (node.tag === BADGE_TAG && node.children.some((child) => child.type !== 'text'))
147
152
  return `writes an element in <${BADGE_TAG}>`;
@@ -42,6 +42,8 @@
42
42
  "BADGE_TOO_LONG": "This badge holds more than {max} characters: keep a badge to a number or a word or two, and write longer text beside it.",
43
43
  "BOX_NESTED": "A frame cannot stand inside another frame: put it after the frame, or use a heading inside it.",
44
44
  "TASK_NESTED": "A task cannot stand inside another task: put it after the task, or make it a sub-task (astl-subtask).",
45
+ "TABLE_INVALID": "A table holds a caption (<caption>, optional, first), then rows (<tr>) in a head (<thead>) and bodies (<tbody>), and each row cells (<th>, <td>) that cover the same columns as the other rows; a span (colspan, rowspan) stays within the rows of its part.",
46
+ "TABLE_TOO_LARGE": "A table has at most {maxColumns} columns and {maxRows} rows; this one has {columns} columns and {rows} rows.",
45
47
  "HELP_UNGRADED": "Element <{tag}> works only inside a graded interaction or on a page with one. Move it there: for now it is left out.",
46
48
  "HELP_EMPTY": "Element <{tag}> is empty, so it is left out. Write its text or remove it.",
47
49
  "PAGE_HELP_UNCHECKED": "Page {page}{titled, select, yes { (“{title}”)} other {}} has help for students but no Check of its own: turn on “Check this page”. Until then the player adds that Check by itself.",
@@ -42,6 +42,8 @@
42
42
  "BADGE_TOO_LONG": "Ten znaczek ma więcej niż {max} znaków: w znaczku zostaw liczbę albo słowo lub dwa, a dłuższy tekst napisz obok.",
43
43
  "BOX_NESTED": "Ramki nie można wstawić do innej ramki: postaw ją za ramką albo użyj w niej nagłówka.",
44
44
  "TASK_NESTED": "Zadania nie można wstawić do innego zadania: postaw je za zadaniem albo zrób z niego podpunkt (astl-subtask).",
45
+ "TABLE_INVALID": "Tabela zawiera podpis (<caption>, opcjonalny, na początku), potem wiersze (<tr>) w nagłówku (<thead>) i treści (<tbody>), a każdy wiersz komórki (<th>, <td>) zajmujące te same kolumny co inne wiersze; scalenie (colspan, rowspan) nie wychodzi poza wiersze swojej części.",
46
+ "TABLE_TOO_LARGE": "Tabela ma najwyżej {maxColumns} kolumn i {maxRows} wierszy; ta ma kolumn: {columns}, wierszy: {rows}.",
45
47
  "HELP_UNGRADED": "Element <{tag}> działa tylko w ocenianym zadaniu albo na stronie z takim zadaniem. Przenieś go tam: na razie jest pominięty.",
46
48
  "HELP_EMPTY": "Element <{tag}> jest pusty, więc jest pominięty. Wpisz jego treść albo go usuń.",
47
49
  "PAGE_HELP_UNCHECKED": "Strona {page}{titled, select, yes { („{title}”)} other {}} ma pomoc dla uczniów, ale nie ma własnego sprawdzania: włącz „Sprawdź tę stronę”. Do tego czasu odtwarzacz sam dodaje to sprawdzanie.",