@memorysmithapp/markdown-renderer 0.8.5 → 0.10.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.
package/dist/edit/live.js CHANGED
@@ -573,6 +573,13 @@ function build(state) {
573
573
  block(from, to, 'diagram', `diagram:${source}`, () => createElement(Snippet, { text: source }));
574
574
  break;
575
575
  }
576
+ // A `table` block is drawn as the table it asks for while the author is elsewhere, where the
577
+ // host reaches the notebook's tables, and edited as its lines (§7.15, #138).
578
+ const fence = construct.open ? doc.sliceString(construct.open.from, construct.open.to) : '';
579
+ if (host.queryTable && !open && alone(from, to) && /^\s*(`{3,}|~{3,})\s*table\s*$/.test(fence)) {
580
+ block(from, to, 'diagram', `table-block:${source}`, () => createElement(Snippet, { text: source }));
581
+ break;
582
+ }
576
583
  codeLines(construct, out, doc, text);
577
584
  // The language, chosen at the block's top right from every grammar Prism carries (#84).
578
585
  if (construct.open) {
@@ -640,6 +647,20 @@ function build(state) {
640
647
  break;
641
648
  }
642
649
  case 'wikilink': {
650
+ // A target that writes a parameter leads nowhere until a notebook is created from the model
651
+ // (§7.14): its label is drawn, and there is nothing to follow.
652
+ if (construct.parameter) {
653
+ out.push(mark('cm-ms-wikilink cm-ms-wikilink-parameter', { title: host.strings.parameterLink }).range(construct.label.from, construct.label.to));
654
+ if (touches(from, to)) {
655
+ out.push(syntax.range(from, construct.label.from));
656
+ out.push(syntax.range(construct.label.to, to));
657
+ }
658
+ else {
659
+ out.push(hide.range(from, construct.label.from));
660
+ out.push(hide.range(construct.label.to, to));
661
+ }
662
+ break;
663
+ }
643
664
  const pending = host.reaches(construct.target) === 0 && !host.keeps(construct.target);
644
665
  if (construct.embed && host.keeps(construct.target) && !touches(from, to)) {
645
666
  const source = text.slice(from, to);
@@ -727,6 +748,10 @@ function build(state) {
727
748
  case 'blockId':
728
749
  out.push(mark('cm-ms-block-id').range(from, to));
729
750
  break;
751
+ case 'parameter':
752
+ // A decoration over the characters, which stay text the author edits (§7.14).
753
+ out.push(mark('cm-ms-parameter', { title: host.strings.parameter, 'data-parameter': construct.name }).range(from, to));
754
+ break;
730
755
  case 'html':
731
756
  case 'definition':
732
757
  out.push(mark('cm-ms-raw').range(from, to));
package/dist/embeds.js CHANGED
@@ -16,6 +16,7 @@
16
16
  * and never blocks (§4.1). Wherever expansion cannot happen the embed becomes
17
17
  * a link and is never dropped, which is what `demoteEmbeds` does.
18
18
  */
19
+ import { hasParameterReference } from './parameters.js';
19
20
  import { codeRegions, fenceRegions, headingKey, insideCode, insideTable, outsideCode, tableRegions } from './source.js';
20
21
  /** Same shape the link extractor matches, plus the leading `!`. */
21
22
  const EMBED = /!\[\[([^\]|#]+?)(?:#([^\]|]+?))?(?:\|[^\]]*?)?\]\]/g;
@@ -47,6 +48,10 @@ keeps = () => false, limit = EMBED_LIMIT) {
47
48
  const target = (match[1] ?? '').trim();
48
49
  if (!target)
49
50
  continue;
51
+ // A target that writes a parameter names nothing to transclude (§7.14): it stays in the run,
52
+ // demoted to the wikilink the parameter is drawn as.
53
+ if (hasParameterReference(target))
54
+ continue;
50
55
  // A file is not a note, so there is nothing to transclude: it is left in
51
56
  // the text run, where the wikilink pass turns it into the attachment the
52
57
  // page draws by its type.
package/dist/host.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type NoteStrings, type NoteStringsInput } from './strings.js';
3
+ import type { TablePage, TableRequest } from './table-block.js';
3
4
  import { type Scheme, type Theme } from './theme.js';
4
5
  /**
5
6
  * The host contract: everything the renderer needs from the notebook a note lives in, given by
@@ -43,6 +44,24 @@ export interface NoteHost {
43
44
  * before it is reached (#94): a host that loads from the network may cache what it answered.
44
45
  */
45
46
  readonly loadNote?: (name: string) => Promise<EmbeddedNote | null>;
47
+ /**
48
+ * The rows a `table` block asks for (`SPEC.md` §7.15, #138): the table it names, the columns, the
49
+ * filter as written, the order, the page and its size, and the column to sum. The host runs the
50
+ * filter and answers the table's columns, the page's rows, the row count of the whole filter, the
51
+ * total and when the rows were read; `null` says the notebook keeps no table of that name. A block
52
+ * that cannot be read asks nothing. Without it, a `table` block is a code block, its lines as
53
+ * written, as it is wherever no tables are kept. The package never fetches; `runTableQuery`
54
+ * answers a request from rows held in memory.
55
+ */
56
+ readonly queryTable?: (request: TableRequest) => Promise<TablePage | null>;
57
+ /**
58
+ * Whether the note is being drawn for paper or a PDF (#139). Each `table` block then asks
59
+ * `queryTable` for every row its filter returns, in its declared order, and is drawn with no
60
+ * control, closed by the line naming what was read. It is the host that knows: an answer cannot
61
+ * arrive between the browser's print command and its page, so give it, wait until no
62
+ * `[aria-busy="true"]` is left under the note, then print. Defaults to `false`.
63
+ */
64
+ readonly printing?: boolean;
46
65
  /**
47
66
  * Whether the reader may tick the task boxes of this note. Defaults to `false`: every box shows
48
67
  * its state and none answers a click.
@@ -236,6 +255,8 @@ export interface ResolvedHost {
236
255
  readonly navigate: (address: string) => void;
237
256
  readonly remoteNotice: boolean;
238
257
  readonly loadNote: ((name: string) => Promise<EmbeddedNote | null>) | null;
258
+ readonly queryTable: ((request: TableRequest) => Promise<TablePage | null>) | null;
259
+ readonly printing: boolean;
239
260
  readonly keeps: (name: string) => boolean;
240
261
  readonly suggest: ((query: string) => readonly string[] | PromiseLike<readonly string[]>) | null;
241
262
  readonly attach: ((file: File, attributes: AttachAttributes, progress: (report: AttachProgress) => void) => string | PromiseLike<string>) | null;
package/dist/host.js CHANGED
@@ -21,6 +21,8 @@ export const HOST_KEYS = Object.keys({
21
21
  targetAddress: 1,
22
22
  navigate: 1,
23
23
  loadNote: 1,
24
+ queryTable: 1,
25
+ printing: 1,
24
26
  writable: 1,
25
27
  onToggleTask: 1,
26
28
  keeps: 1,
@@ -54,6 +56,8 @@ export function resolveHost(host) {
54
56
  navigate: host.navigate ?? ((address) => window.location.assign(address)),
55
57
  remoteNotice: host.remoteNotice ?? true,
56
58
  loadNote: host.loadNote ?? null,
59
+ queryTable: host.queryTable ?? null,
60
+ printing: host.printing ?? false,
57
61
  keeps: host.keeps ?? never,
58
62
  suggest: host.suggest ?? null,
59
63
  attach: host.attach ?? null,
package/dist/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilin
11
11
  export { ordinalAt, taskBoxes, taskCheckedAt, toggleTaskAt } from './tasklist.js';
12
12
  export { readProperties, type NoteProperties, type PropertyEntry, type PropertyShape } from './properties.js';
13
13
  export { DELEGATED_TO_THE_BASE_PARSER, unclassified } from './delegated.js';
14
+ export { runTableQuery, type TableColumn, type TableColumnKind, type TablePage, type TableRequest, type TableRow, type TableSchema, type TableSortKey, type TableValue, } from './table-block.js';
package/dist/index.js CHANGED
@@ -9,3 +9,4 @@ export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilin
9
9
  export { ordinalAt, taskBoxes, taskCheckedAt, toggleTaskAt } from './tasklist.js';
10
10
  export { readProperties } from './properties.js';
11
11
  export { DELEGATED_TO_THE_BASE_PARSER, unclassified } from './delegated.js';
12
+ export { runTableQuery, } from './table-block.js';
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Parameter references, `{{name}}` (§7.14, #134).
3
+ *
4
+ * A model of a notebook marks with a reference where a value goes, and what fills it in is the
5
+ * implementation that creates a notebook from the model, never this package: the reading surface
6
+ * draws a reference as it stands, unresolved, as a parameter and not as broken text. Nothing here
7
+ * changes a byte of the note.
8
+ *
9
+ * A reference is exactly `{{`, a name and `}}`, the shortest match, so `{{{name}}}` is a literal
10
+ * `{`, a reference and a literal `}`. It needs two unescaped `{`: `\{{name}}` and `{\{name}}` are
11
+ * text, and so is a run that does not close as one. Where it is not a reference — code, math, a
12
+ * link's destination, an autolink, raw HTML — is decided by the parser, which is why the reading
13
+ * surface finds it in the tree (`remarkParameters`) and the editor on the tree's text
14
+ * (`analyze.ts`); this module only knows the characters.
15
+ */
16
+ /** One reference, as a range of the text it was found in. */
17
+ export interface ParameterReference {
18
+ /** The name, normalised to NFC: two spellings of one name are one parameter. */
19
+ readonly name: string;
20
+ readonly from: number;
21
+ readonly to: number;
22
+ }
23
+ /**
24
+ * The references a run of source text writes, in order. A `{{` preceded by an odd run of
25
+ * backslashes is escaped, and is text.
26
+ */
27
+ export declare function parameterReferences(source: string): ParameterReference[];
28
+ /** Whether a run of source text writes a reference: a wikilink target that does is no link (§5.2). */
29
+ export declare function hasParameterReference(source: string): boolean;
30
+ /** A piece of text: the characters as they are drawn, or a reference. */
31
+ export type ParameterPiece = string | ParameterReference;
32
+ /**
33
+ * A text cut at its references, for the places that draw the characters as they were typed: the
34
+ * value of a property, the name of a note.
35
+ */
36
+ export declare function splitParameters(text: string): ParameterPiece[];
37
+ interface MdastNode {
38
+ type: string;
39
+ value?: string;
40
+ url?: string;
41
+ children?: MdastNode[];
42
+ position?: {
43
+ start?: {
44
+ offset?: number;
45
+ };
46
+ end?: {
47
+ offset?: number;
48
+ };
49
+ };
50
+ data?: {
51
+ hName?: string;
52
+ hProperties?: Record<string, unknown>;
53
+ };
54
+ }
55
+ /**
56
+ * `{{name}}` becomes a parameter, drawn unresolved (§7.14).
57
+ *
58
+ * It runs before every other transform of the reading surface, while each text node still has the
59
+ * position of the characters it came from: an escape is gone from the value, and only the source
60
+ * says a `{{` was written `\{{`. The nodes the parser does not read as text — code, math, raw
61
+ * HTML, a destination — never reach it, and a link that is not written with brackets is an
62
+ * autolink, whose text is its address.
63
+ */
64
+ export interface ParameterOptions {
65
+ /** The title of a parameter on the page, in the reader's language. */
66
+ readonly title?: string | undefined;
67
+ }
68
+ export declare function remarkParameters(options?: ParameterOptions): (tree: MdastNode, file: {
69
+ value?: unknown;
70
+ }) => void;
71
+ export {};
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Parameter references, `{{name}}` (§7.14, #134).
3
+ *
4
+ * A model of a notebook marks with a reference where a value goes, and what fills it in is the
5
+ * implementation that creates a notebook from the model, never this package: the reading surface
6
+ * draws a reference as it stands, unresolved, as a parameter and not as broken text. Nothing here
7
+ * changes a byte of the note.
8
+ *
9
+ * A reference is exactly `{{`, a name and `}}`, the shortest match, so `{{{name}}}` is a literal
10
+ * `{`, a reference and a literal `}`. It needs two unescaped `{`: `\{{name}}` and `{\{name}}` are
11
+ * text, and so is a run that does not close as one. Where it is not a reference — code, math, a
12
+ * link's destination, an autolink, raw HTML — is decided by the parser, which is why the reading
13
+ * surface finds it in the tree (`remarkParameters`) and the editor on the tree's text
14
+ * (`analyze.ts`); this module only knows the characters.
15
+ */
16
+ import { decodeString } from 'micromark-util-decode-string';
17
+ /**
18
+ * A reference: a letter or `_`, then letters, combining marks, digits, `_` and `-`, between
19
+ * double braces. The same class of word a callout's type is (§7.1).
20
+ */
21
+ const REFERENCE = /\{\{([\p{L}_][\p{L}\p{M}\p{N}_-]*)\}\}/gu;
22
+ /**
23
+ * The references a run of source text writes, in order. A `{{` preceded by an odd run of
24
+ * backslashes is escaped, and is text.
25
+ */
26
+ export function parameterReferences(source) {
27
+ const found = [];
28
+ for (const match of source.matchAll(REFERENCE)) {
29
+ const at = match.index ?? 0;
30
+ let backslashes = 0;
31
+ while (source[at - 1 - backslashes] === '\\')
32
+ backslashes += 1;
33
+ if (backslashes % 2 === 1)
34
+ continue;
35
+ found.push({ name: (match[1] ?? '').normalize('NFC'), from: at, to: at + match[0].length });
36
+ }
37
+ return found;
38
+ }
39
+ /** Whether a run of source text writes a reference: a wikilink target that does is no link (§5.2). */
40
+ export function hasParameterReference(source) {
41
+ return parameterReferences(source).length > 0;
42
+ }
43
+ /**
44
+ * A text cut at its references, for the places that draw the characters as they were typed: the
45
+ * value of a property, the name of a note.
46
+ */
47
+ export function splitParameters(text) {
48
+ const pieces = [];
49
+ let cursor = 0;
50
+ for (const reference of parameterReferences(text)) {
51
+ if (reference.from > cursor)
52
+ pieces.push(text.slice(cursor, reference.from));
53
+ pieces.push(reference);
54
+ cursor = reference.to;
55
+ }
56
+ if (cursor < text.length || pieces.length === 0)
57
+ pieces.push(text.slice(cursor));
58
+ return pieces;
59
+ }
60
+ /** The characters a container puts in front of a continuation line: a quote's `>`, an indent. */
61
+ const CONTINUATION = /^(?:[ \t]*>)*[ \t]*/;
62
+ /**
63
+ * What the parser made of a run of source, as it made a text node's value of it: the escapes and
64
+ * the character references decoded, each line before a soft break without its trailing spaces, and
65
+ * each continuation line without what its container put in front of it.
66
+ */
67
+ function decoded(source) {
68
+ const lines = source.split('\n');
69
+ return decodeString(lines
70
+ .map((line, index) => {
71
+ const head = index === 0 ? line : line.replace(CONTINUATION, '');
72
+ return index === lines.length - 1 ? head : head.replace(/[ \t]+$/, '');
73
+ })
74
+ .join('\n'));
75
+ }
76
+ /**
77
+ * The value of a text node, cut at the references its source writes, or `null` when there is none
78
+ * or the value is not what this module reads the source as, which leaves the node as it was: a
79
+ * reference not drawn is the safe failure, a value drawn wrong is not.
80
+ */
81
+ function cutText(source, value) {
82
+ const references = parameterReferences(source);
83
+ if (references.length === 0)
84
+ return null;
85
+ const pieces = [];
86
+ let cursor = 0;
87
+ for (const reference of references) {
88
+ pieces.push(decoded(source.slice(cursor, reference.from)), reference);
89
+ cursor = reference.to;
90
+ }
91
+ pieces.push(decoded(source.slice(cursor)));
92
+ const drawn = pieces.map((piece) => (typeof piece === 'string' ? piece : source.slice(piece.from, piece.to))).join('');
93
+ return drawn === value ? pieces.filter((piece) => piece !== '') : null;
94
+ }
95
+ /** The node a reference becomes: a span the stylesheet draws as a parameter, holding what was typed. */
96
+ function parameterNode(name, typed, title) {
97
+ return {
98
+ type: 'parameter',
99
+ data: { hName: 'span', hProperties: { className: ['parameter'], dataParameter: name, ...(title ? { title } : {}) } },
100
+ children: [{ type: 'text', value: typed }],
101
+ };
102
+ }
103
+ export function remarkParameters(options = {}) {
104
+ return (tree, file) => {
105
+ const source = typeof file.value === 'string' ? file.value : String(file.value ?? '');
106
+ if (!source.includes('{{'))
107
+ return;
108
+ const visit = (parent) => {
109
+ if (!parent.children)
110
+ return;
111
+ parent.children = parent.children.flatMap((child) => {
112
+ if (child.type === 'link') {
113
+ const from = child.position?.start?.offset;
114
+ if (from === undefined || source[from] !== '[')
115
+ return [child];
116
+ }
117
+ if (child.type !== 'text') {
118
+ visit(child);
119
+ return [child];
120
+ }
121
+ const from = child.position?.start?.offset;
122
+ const to = child.position?.end?.offset;
123
+ if (from === undefined || to === undefined || typeof child.value !== 'string')
124
+ return [child];
125
+ const typed = source.slice(from, to);
126
+ const pieces = cutText(typed, child.value);
127
+ if (!pieces)
128
+ return [child];
129
+ return pieces.map((piece) => typeof piece === 'string' ? { type: 'text', value: piece } : parameterNode(piece.name, typed.slice(piece.from, piece.to), options.title));
130
+ });
131
+ };
132
+ visit(tree);
133
+ };
134
+ }
package/dist/reading.d.ts CHANGED
@@ -3,4 +3,6 @@ import type { PluggableList } from 'unified';
3
3
  * The remark plugins of the reading surface, in their order. `planFootnotes` reads a note
4
4
  * through the same list, so it counts the references this surface draws and no other.
5
5
  */
6
- export declare function readingPlugins(titleOf: (kind: string) => string | undefined): PluggableList;
6
+ export declare function readingPlugins(titleOf: (kind: string) => string | undefined,
7
+ /** The title a parameter carries, in the reader's language; none for a reading that draws nothing. */
8
+ parameterTitle?: string): PluggableList;
package/dist/reading.js CHANGED
@@ -2,13 +2,16 @@
2
2
  // and the diagnostic read a note through the same list, so a notice never disagrees with the page.
3
3
  import remarkGfm from 'remark-gfm';
4
4
  import remarkMath from 'remark-math';
5
+ import { remarkParameters } from './parameters.js';
5
6
  import { remarkCallouts } from './remark-callouts.js';
6
7
  import { remarkBlockIds, remarkHighlight, remarkMathDollarRule } from './remark-ring.js';
7
8
  /**
8
9
  * The remark plugins of the reading surface, in their order. `planFootnotes` reads a note
9
10
  * through the same list, so it counts the references this surface draws and no other.
10
11
  */
11
- export function readingPlugins(titleOf) {
12
+ export function readingPlugins(titleOf,
13
+ /** The title a parameter carries, in the reader's language; none for a reading that draws nothing. */
14
+ parameterTitle) {
12
15
  return [
13
16
  /**
14
17
  * `singleTilde: false` is a decision and not a default.
@@ -22,6 +25,9 @@ export function readingPlugins(titleOf) {
22
25
  * the specification says they get, which is nothing.
23
26
  */
24
27
  [remarkGfm, { singleTilde: false }],
28
+ // First of the transforms: it reads the positions the parser gave each text node, which the
29
+ // transforms after it do not keep, and they read a parameter as one character of the text.
30
+ [remarkParameters, { title: parameterTitle }],
25
31
  [remarkCallouts, { titleOf }],
26
32
  remarkHighlight,
27
33
  remarkBlockIds,
@@ -33,20 +33,60 @@ function isText(node) {
33
33
  *
34
34
  * It carries no meaning beyond emphasis: no edge, no attribute, no index
35
35
  * entry. The `==` never reaches the screen.
36
+ *
37
+ * A parameter (§7.14) is read as one character of the text around it, so
38
+ * `=={{client}}==` marks the parameter: `remarkParameters` ran first and cut
39
+ * the text node at it, and a run of text and parameters is marked as the one
40
+ * text it was written as.
36
41
  */
37
42
  const HIGHLIGHT = /==([^=]+)==/g;
43
+ /** Where a parameter stands in the text of a run while it is marked. */
44
+ const STAND_IN = '\uFFFC';
38
45
  export function remarkHighlight() {
39
46
  return (tree) => walk(tree, (parent) => {
40
- parent.children = (parent.children ?? []).flatMap((child) => {
41
- if (!isText(child) || !child.value?.includes('=='))
42
- return [child];
43
- return split(child.value, HIGHLIGHT, (inner) => ({
44
- type: 'emphasis',
45
- data: { hName: 'mark' },
46
- children: [{ type: 'text', value: inner }],
47
- }));
47
+ const children = [];
48
+ let run = [];
49
+ const flush = () => {
50
+ children.push(...highlightRun(run));
51
+ run = [];
52
+ };
53
+ for (const child of parent.children ?? []) {
54
+ if (isText(child) || child.type === 'parameter')
55
+ run.push(child);
56
+ else {
57
+ flush();
58
+ children.push(child);
59
+ }
60
+ }
61
+ flush();
62
+ parent.children = children;
63
+ });
64
+ }
65
+ /** A run of text and parameters, with its marked text made marks. */
66
+ function highlightRun(run) {
67
+ if (!run.some((node) => isText(node) && node.value?.includes('==')))
68
+ return run;
69
+ const parameters = run.filter((node) => node.type === 'parameter');
70
+ const text = run.map((node) => (node.type === 'parameter' ? STAND_IN : (node.value ?? ''))).join('');
71
+ // A stand-in the author typed would be taken for a parameter: such a run is marked node by node.
72
+ if ((text.match(new RegExp(STAND_IN, 'g')) ?? []).length !== parameters.length) {
73
+ return run.flatMap((node) => (isText(node) && node.value ? split(node.value, HIGHLIGHT, mark) : [node]));
74
+ }
75
+ let next = 0;
76
+ const restore = (nodes) => nodes.flatMap((node) => {
77
+ if (node.children)
78
+ return [{ ...node, children: restore(node.children) }];
79
+ if (!isText(node) || !node.value?.includes(STAND_IN))
80
+ return [node];
81
+ return node.value.split(STAND_IN).flatMap((part, index) => {
82
+ const parameter = index > 0 ? parameters[next++] : undefined;
83
+ return [...(parameter ? [parameter] : []), ...(part ? [{ type: 'text', value: part }] : [])];
48
84
  });
49
85
  });
86
+ return restore(split(text, HIGHLIGHT, mark));
87
+ }
88
+ function mark(inner) {
89
+ return { type: 'emphasis', data: { hName: 'mark' }, children: [{ type: 'text', value: inner }] };
50
90
  }
51
91
  /**
52
92
  * `^identifier` at the end of a block names that block (§7.7), and is never
package/dist/source.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // The text helpers of the reading surface: what a note becomes before the parser reads it.
2
2
  // Nothing here rewrites the note a host keeps; each function returns a new string for display.
3
3
  import { readDimensions, writeDimensions } from './image-dimensions.js';
4
+ import { hasParameterReference } from './parameters.js';
4
5
  /**
5
6
  * A note is bytes the notebook wrote, and a notebook written on Windows, or in a
6
7
  * desktop editor, or pasted from anywhere, carries CRLF. Every reader in this
@@ -336,6 +337,11 @@ function resolveWikilinksIn(body, resolve, keeps) {
336
337
  const text = displayText(clean, label, target, (name) => embed && keeps(name));
337
338
  if (!clean)
338
339
  return `[${text}](pending:)`;
340
+ // A target that writes a parameter names no note until a notebook is created from the model
341
+ // (§7.14): it is drawn as the parameter it holds, neither a link nor pending, and an embed of
342
+ // it transcludes nothing.
343
+ if (hasParameterReference(clean))
344
+ return `[${text}](parameter:)`;
339
345
  // The pipe is read by WHAT THE TARGET IS: a note takes the alias, an
340
346
  // attachment takes the dimensions, and a target that resolves to neither
341
347
  // takes the alias — because reading it as a dimension would discard text
package/dist/strings.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { TableNoticeCode } from './table-block.js';
1
2
  /**
2
3
  * The words the reading surface shows of its own, around what a note says.
3
4
  *
@@ -23,6 +24,32 @@ export interface NoteStrings {
23
24
  readonly pendingLink: string;
24
25
  /** The title of an address the surface does not follow. */
25
26
  readonly refusedLink: string;
27
+ /** The title of a parameter reference, `{{name}}`, which a notebook created from the model fills in (§7.14). */
28
+ readonly parameter: string;
29
+ /** The title of a wikilink whose target writes a parameter, which leads nowhere until then. */
30
+ readonly parameterLink: string;
31
+ /** How many rows the filter of a `table` block returns (§7.15). */
32
+ readonly tableRows: (count: number) => string;
33
+ /** Which page of a `table` block is drawn, of how many. */
34
+ readonly tablePage: (page: number, pages: number) => string;
35
+ /** The buttons that move a `table` block to the page before and after. */
36
+ readonly tablePrevious: string;
37
+ readonly tableNext: string;
38
+ /** The label of the row that closes a table with its total. */
39
+ readonly tableTotal: string;
40
+ /** What a `table` block says when its filter returns no row. */
41
+ readonly tableEmpty: string;
42
+ /** The title of a column's header, which sorts the table by it for the reader alone. */
43
+ readonly tableSortBy: (column: string) => string;
44
+ /** What a `table` block says in place of its table, by the code of its notice (§7.13); `table` is what it names, if anything. */
45
+ readonly tableProblem: (code: TableNoticeCode, table: string | null) => string;
46
+ /** The line that closes a printed `table` block: the table, its filter or `null`, how many rows and when they were read. */
47
+ readonly tablePrinted: (read: {
48
+ readonly table: string;
49
+ readonly filter: string | null;
50
+ readonly count: number;
51
+ readonly readAt: string;
52
+ }) => string;
26
53
  /** The title of an embed naming a file the notebook does not keep. */
27
54
  readonly attachmentMissing: string;
28
55
  /** A card's ways to a file: open it where a browser shows it, and save it (#77). */
package/dist/strings.js CHANGED
@@ -39,6 +39,32 @@ export const ENGLISH = {
39
39
  footnoteBack: (number) => `Back to reference ${number}`,
40
40
  pendingLink: 'Pending link: the target note does not exist yet.',
41
41
  refusedLink: 'This address is not one the reading surface follows, so the text stays and the link does not.',
42
+ parameter: 'Parameter: filled in when a notebook is created from this model.',
43
+ parameterLink: 'A link to a parameter: it leads to a note once a notebook is created from this model.',
44
+ tableRows: (count) => (count === 1 ? '1 row' : `${count.toLocaleString('en-US')} rows`),
45
+ tablePage: (page, pages) => `Page ${page} of ${pages}`,
46
+ tablePrevious: 'Previous page',
47
+ tableNext: 'Next page',
48
+ tableTotal: 'Total',
49
+ tableEmpty: 'No row answers this filter.',
50
+ tableSortBy: (column) => `Sort by ${column}, for you alone: the note keeps its order`,
51
+ tableProblem: (code, table) => {
52
+ switch (code) {
53
+ case 'table-unnamed':
54
+ return 'This table block names no table: write its name once, as table: name.';
55
+ case 'table-key-unknown':
56
+ return 'A table block has six keys, and this line is none of them:';
57
+ case 'table-key-invalid':
58
+ return 'This key is written twice, or its value cannot be read:';
59
+ case 'table-column-unknown':
60
+ return `The table ${table ?? ''} has no such column:`;
61
+ case 'table-filter-invalid':
62
+ return 'This filter cannot be answered:';
63
+ case 'table-pending':
64
+ return `This notebook keeps no table named ${table ?? ''} yet.`;
65
+ }
66
+ },
67
+ tablePrinted: ({ table, filter, count, readAt }) => `Table ${table}${filter === null ? '' : `, filtered by ${filter}`}: ${count === 1 ? '1 row' : `${count.toLocaleString('en-US')} rows`}, read on ${readAt}.`,
42
68
  attachmentMissing: 'This notebook keeps no file under that name.',
43
69
  attachmentOpen: 'Open',
44
70
  attachmentDownload: 'Download',