@memorysmithapp/markdown-renderer 0.8.4 → 0.9.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @memorysmithapp/markdown-renderer
2
2
 
3
- A React component that draws the body of a MemorySmith note exactly as MemorySmith's reading page does: callouts, wikilinks, embedded notes, task boxes, code with highlighting and diagrams, mathematics, footnotes — the notation of the [MemorySmith Markdown Specification](https://www.npmjs.com/package/@memorysmithapp/markdown-spec).
3
+ A React component that draws the body of a MemorySmith note exactly as MemorySmith's reading page does: callouts, wikilinks, embedded notes, task boxes, code with highlighting and diagrams, mathematics, footnotes, the parameters of a model — the notation of the [MemorySmith Markdown Specification](https://www.npmjs.com/package/@memorysmithapp/markdown-spec).
4
4
 
5
5
  The package knows no API, no router and no i18n library. Everything it needs from the notebook a note lives in reaches it as props, and it never rewrites the note: ticking a task box reports which box, and the host applies it.
6
6
 
package/dist/Markdown.js CHANGED
@@ -12,7 +12,7 @@ import { highlightLanguage, highlightTree, languageToLoad, loadGrammar } from '.
12
12
  import { useHost } from './host.js';
13
13
  import { readDimensions, readImageAlt, sizedAttributes } from './image-dimensions.js';
14
14
  import { choiceTargetOf, LinkChoice } from './LinkChoice.js';
15
- import { toUnixNewlines } from './markdown.js';
15
+ import { toUnixNewlines } from './source.js';
16
16
  import { MermaidDiagram } from './MermaidDiagram.js';
17
17
  import { readingPlugins } from './reading.js';
18
18
  import { CLOBBER_PREFIX, rehypeFootnoteRun, rehypeFootnoteSection } from './footnotes.js';
@@ -188,6 +188,11 @@ export function MarkdownAnchor({ href, children, node: _node, ...rest }) {
188
188
  const name = measured ? address.slice(0, at) : address;
189
189
  return _jsx(Attachment, { name: name, size: measured ?? { width: null, height: null, percent: null } });
190
190
  }
191
+ // A wikilink whose target writes a parameter (§7.14): it leads nowhere until a notebook is
192
+ // created from the model, so it is the parameter it holds, drawn, and not something to follow.
193
+ if (href?.startsWith('parameter:')) {
194
+ return (_jsx("span", { className: "wikilink-parameter", title: host.strings.parameterLink, children: children }));
195
+ }
191
196
  if (href?.startsWith('pending:')) {
192
197
  const pending = (label) => (_jsx("span", { className: "wikilink-pending", title: host.strings.pendingLink, children: label }));
193
198
  return wikilinkSlot ? drawSlot(wikilinkSlot, { pending: true, children, link: pending }) : pending(children);
@@ -373,7 +378,7 @@ export function Markdown({ children, source, onToggleTask, taskSave, writable =
373
378
  return (
374
379
  // The pass that draws a cut note's footnotes continues the note rather than opening a run,
375
380
  // so its section keeps the space a section takes at the end of a note.
376
- _jsx("div", { className: footnotes === 'section' ? 'markdown footnotes-run' : 'markdown', children: _jsx(ReactMarkdown, { remarkPlugins: readingPlugins(calloutTitle),
381
+ _jsx("div", { className: footnotes === 'section' ? 'markdown footnotes-run' : 'markdown', children: _jsx(ReactMarkdown, { remarkPlugins: readingPlugins(calloutTitle, strings.parameter),
377
382
  // Raw HTML is NOT enabled, and its absence is the point: no
378
383
  // `rehype-raw` is loaded, so a note carrying `<script>` is text. It is
379
384
  // a security boundary rather than a rendering preference, because a
package/dist/NoteBody.js CHANGED
@@ -7,14 +7,14 @@ import { HOST_KEYS, HostProvider, resolveHost, useHost } from './host.js';
7
7
  import { planFootnotes } from './footnotes.js';
8
8
  import { Markdown } from './Markdown.js';
9
9
  import { readingPlugins } from './reading.js';
10
- import { bodyStart, hideComments, remoteImageHosts, resolveWikilinks } from './markdown.js';
10
+ import { bodyStart, hideComments, remoteImageHosts, resolveWikilinks } from './source.js';
11
11
  import { readProperties } from './properties.js';
12
12
  import { Properties } from './PropertiesBlock.js';
13
13
  import { useTaskSaves } from './task-saves.js';
14
14
  import { taskBoxes } from './tasklist.js';
15
15
  import { rootStyle } from './theme.js';
16
16
  import { Transclusion } from './Transclusion.js';
17
- import { splitEmbeds } from './transclusion.js';
17
+ import { splitEmbeds } from './embeds.js';
18
18
  import { wikilinkAddress } from './wikilink-address.js';
19
19
  /** The editor, loaded the first time a note is edited, so a host that only draws never loads it. */
20
20
  const NoteEditor = lazy(() => import('./edit/NoteEditor.js').then((module) => ({ default: module.NoteEditor })));
@@ -13,6 +13,11 @@
13
13
  */
14
14
  import type { ReactNode } from 'react';
15
15
  import { type NoteProperties } from './properties.js';
16
+ /**
17
+ * Text as it was typed, with each parameter it writes drawn as one (§7.14): a value of the
18
+ * frontmatter, or the name of a note, in a model.
19
+ */
20
+ export declare function useParameters(): (text: string) => ReactNode;
16
21
  export declare function Properties({ properties }: {
17
22
  properties: NoteProperties;
18
23
  }): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
@@ -1,30 +1,46 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useHost } from './host.js';
3
3
  import { MarkdownAnchor } from './Markdown.js';
4
+ import { hasParameterReference, splitParameters } from './parameters.js';
4
5
  import { DRAWN_RESERVED_KEYS, isTrue, VALUE_LINK, } from './properties.js';
5
6
  import { drawSlot, useSlot } from './slots.js';
6
7
  import { wikilinkAddress } from './wikilink-address.js';
8
+ /**
9
+ * Text as it was typed, with each parameter it writes drawn as one (§7.14): a value of the
10
+ * frontmatter, or the name of a note, in a model.
11
+ */
12
+ export function useParameters() {
13
+ const { strings } = useHost();
14
+ return (text) => {
15
+ const pieces = splitParameters(text);
16
+ if (pieces.length === 1 && typeof pieces[0] === 'string')
17
+ return pieces[0];
18
+ return pieces.map((piece, index) => typeof piece === 'string' ? (piece) : (_jsx("span", { className: "parameter", "data-parameter": piece.name, title: strings.parameter, children: text.slice(piece.from, piece.to) }, index)));
19
+ };
20
+ }
7
21
  /**
8
22
  * A value as the note means it: a wikilink a link to where the host resolved it — the note, the
9
23
  * choice, or the pending marker — a Markdown link or a bare address to the web a link to it, each
10
24
  * through the anchor the body's links take, so the address filter holds and a theme's `wikilink`
11
- * slot draws them too; everything else as text, never as markup.
25
+ * slot draws them too; a parameter as a parameter; everything else as text, never as markup.
12
26
  */
13
27
  function useValue() {
14
28
  const host = useHost();
29
+ const drawn = useParameters();
15
30
  return (text) => {
16
31
  const parts = [];
17
32
  let cursor = 0;
18
33
  for (const match of text.matchAll(VALUE_LINK)) {
19
34
  const at = match.index ?? 0;
20
35
  if (at > cursor)
21
- parts.push(text.slice(cursor, at));
36
+ parts.push(drawn(text.slice(cursor, at)));
22
37
  const [whole, wikiTarget, wikiLabel, mdLabel, mdUrl, rawUrl] = match;
23
38
  if (wikiTarget) {
24
39
  const target = wikiTarget.trim();
25
40
  const name = target.split('#')[0]?.trim() ?? '';
26
- const address = name ? wikilinkAddress(host, name.normalize('NFC')) : null;
27
- parts.push(_jsx(MarkdownAnchor, { href: address ?? `pending:${encodeURIComponent(name)}`, children: wikiLabel?.trim() || target }, at));
41
+ // A target that writes a parameter leads nowhere until a notebook is created from the model.
42
+ const address = hasParameterReference(name) ? 'parameter:' : name ? wikilinkAddress(host, name.normalize('NFC')) : null;
43
+ parts.push(_jsx(MarkdownAnchor, { href: address ?? `pending:${encodeURIComponent(name)}`, children: drawn(wikiLabel?.trim() || target) }, at));
28
44
  }
29
45
  else {
30
46
  parts.push(_jsx(MarkdownAnchor, { href: mdUrl ?? rawUrl, children: mdLabel ?? rawUrl }, at));
@@ -32,7 +48,7 @@ function useValue() {
32
48
  cursor = at + whole.length;
33
49
  }
34
50
  if (cursor < text.length)
35
- parts.push(text.slice(cursor));
51
+ parts.push(drawn(text.slice(cursor)));
36
52
  return parts.length === 1 ? parts[0] : _jsx(_Fragment, { children: parts });
37
53
  };
38
54
  }
@@ -100,8 +116,9 @@ export function Properties({ properties }) {
100
116
  const { strings } = useHost();
101
117
  const slot = useSlot('properties');
102
118
  const value = useValue();
119
+ const drawn = useParameters();
103
120
  if (slot)
104
121
  return drawSlot(slot, { name: properties.name, entries: properties.entries, value });
105
122
  const shown = ordered(properties.entries);
106
- return (_jsxs(_Fragment, { children: [_jsx("h1", { className: properties.name === null ? 'note-title note-unnamed' : 'note-title', children: properties.name ?? strings.unnamedNote }), shown.length > 0 && (_jsxs("details", { className: "properties-box", open: true, children: [_jsx("summary", { children: strings.properties }), _jsx("div", { className: "metadata-container", children: shown.map((entry, index) => (_jsxs("div", { className: "metadata-property", "data-property-type": iconType(entry), children: [_jsx("span", { className: "metadata-property-key", children: entry.key }), _jsx("span", { className: "metadata-property-value", children: _jsx(PropertyValue, { entry: entry, value: value }) })] }, index))) })] }))] }));
123
+ return (_jsxs(_Fragment, { children: [_jsx("h1", { className: properties.name === null ? 'note-title note-unnamed' : 'note-title', children: properties.name === null ? strings.unnamedNote : drawn(properties.name) }), shown.length > 0 && (_jsxs("details", { className: "properties-box", open: true, children: [_jsx("summary", { children: strings.properties }), _jsx("div", { className: "metadata-container", children: shown.map((entry, index) => (_jsxs("div", { className: "metadata-property", "data-property-type": iconType(entry), children: [_jsx("span", { className: "metadata-property-key", children: entry.key }), _jsx("span", { className: "metadata-property-value", children: _jsx(PropertyValue, { entry: entry, value: value }) })] }, index))) })] }))] }));
107
124
  }
@@ -3,8 +3,8 @@ import { useEffect, useState } from 'react';
3
3
  import { useHost } from './host.js';
4
4
  import { Markdown } from './Markdown.js';
5
5
  import { drawSlot, useSlot } from './slots.js';
6
- import { bodyStart, hideComments, resolveWikilinks } from './markdown.js';
7
- import { blockOf, demoteEmbeds, isBlockAnchor, sectionOf } from './transclusion.js';
6
+ import { bodyStart, hideComments, resolveWikilinks } from './source.js';
7
+ import { blockOf, demoteEmbeds, isBlockAnchor, sectionOf } from './embeds.js';
8
8
  import { wikilinkAddress } from './wikilink-address.js';
9
9
  /** The shape of what is coming, in the position it will occupy, while the host answers. */
10
10
  function TransclusionSkeleton({ loading }) {
package/dist/address.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  * **What passes, and why:**
16
16
  *
17
17
  * - `pending:` — ours, and the reason the filter was off in the first place;
18
- * and `attachment:` and `choice:`, ours too.
18
+ * and `attachment:`, `choice:` and `parameter:`, ours too.
19
19
  * - A path of the application (`/`), a relative one (`./`, `../`) and an
20
20
  * anchor of the page (`#`).
21
21
  * - `http:` and `https:` — the web, which is what a note cites.
package/dist/address.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * **What passes, and why:**
16
16
  *
17
17
  * - `pending:` — ours, and the reason the filter was off in the first place;
18
- * and `attachment:` and `choice:`, ours too.
18
+ * and `attachment:`, `choice:` and `parameter:`, ours too.
19
19
  * - A path of the application (`/`), a relative one (`./`, `../`) and an
20
20
  * anchor of the page (`#`).
21
21
  * - `http:` and `https:` — the web, which is what a note cites.
@@ -43,14 +43,15 @@
43
43
  * specification gives to a notation it does not implement.
44
44
  */
45
45
  /**
46
- * `pending:`, `attachment:` and `choice:` are this surface's own: a wikilink
47
- * that matched no note, a reference to a file the notebook keeps beside its
48
- * notes, and a wikilink several notes may answer. None of them leaves the page
46
+ * `pending:`, `attachment:`, `choice:` and `parameter:` are this surface's own:
47
+ * a wikilink that matched no note, a reference to a file the notebook keeps
48
+ * beside its notes, a wikilink several notes may answer, and a wikilink whose
49
+ * target writes a parameter (§7.14). None of them leaves the page
49
50
  * — the anchor of the surface turns each into what it is — and they are listed
50
51
  * here so the filter does not empty them into the refusal case, which says
51
52
  * something else entirely.
52
53
  */
53
- const ALLOWED_SCHEME = /^(https?|mailto|pending|attachment|choice):/i;
54
+ const ALLOWED_SCHEME = /^(https?|mailto|pending|attachment|choice|parameter):/i;
54
55
  /** Anything of the shape `word:`, which is what makes an address absolute. */
55
56
  const HAS_SCHEME = /^[a-z][a-z0-9+.-]*:/i;
56
57
  /**
package/dist/diagnose.js CHANGED
@@ -15,7 +15,8 @@ import { keptImageName } from './kept-image.js';
15
15
  import katex from 'katex';
16
16
  import remarkParse from 'remark-parse';
17
17
  import { unified } from 'unified';
18
- import { bodyStart, codeRegions, hideComments, insideCode, toUnixNewlines } from './markdown.js';
18
+ import { bodyStart, codeRegions, hideComments, insideCode, toUnixNewlines } from './source.js';
19
+ import { hasParameterReference } from './parameters.js';
19
20
  import { readProperties } from './properties.js';
20
21
  import { readingPlugins } from './reading.js';
21
22
  /** The table of §7.13, as `spec.json` carries it: a test holds the two equal. */
@@ -309,6 +310,9 @@ function pending(hidden, split, options, report) {
309
310
  // `[[#Section]]` is a link within the note itself.
310
311
  if (!name)
311
312
  continue;
313
+ // A target that writes a parameter is neither a link nor pending (§7.14).
314
+ if (hasParameterReference(name))
315
+ continue;
312
316
  const embed = match[1] !== undefined;
313
317
  if (answered(name) || (embed && keeps(name)))
314
318
  continue;
@@ -50,6 +50,13 @@ export type Construct = {
50
50
  /** What the page shows: the alias, or the target. */
51
51
  readonly label: Span;
52
52
  readonly embed: boolean;
53
+ /** Its target writes a parameter (§7.14): it leads nowhere until a notebook is created from the model. */
54
+ readonly parameter: boolean;
55
+ } | {
56
+ readonly kind: 'parameter';
57
+ readonly from: number;
58
+ readonly to: number;
59
+ readonly name: string;
53
60
  } | {
54
61
  readonly kind: 'image';
55
62
  readonly from: number;
@@ -15,9 +15,10 @@ import remarkGfm from 'remark-gfm';
15
15
  import remarkMath from 'remark-math';
16
16
  import remarkParse from 'remark-parse';
17
17
  import { unified } from 'unified';
18
- import { codeRegions, commentRegions, insideCode } from '../markdown.js';
18
+ import { codeRegions, commentRegions, insideCode } from '../source.js';
19
19
  import { CALLOUT_MARKER } from '../remark-callouts.js';
20
20
  import { breaksDollarRule } from '../remark-ring.js';
21
+ import { hasParameterReference, parameterReferences } from '../parameters.js';
21
22
  let parser = null;
22
23
  function parse(text) {
23
24
  // The micromark extensions of `readingPlugins`, at its options; the transforms that rewrite the
@@ -76,7 +77,8 @@ export function analyze(text) {
76
77
  : { from: head, to: head + target.length };
77
78
  wikilinks.push({ from, to });
78
79
  // In a table cell the pipe before an alias is escaped, and the backslash is not part of the target.
79
- found.push({ kind: 'wikilink', from, to, target: target.split('#')[0].replace(/\\$/, '').trim(), label, embed });
80
+ const name = target.split('#')[0].replace(/\\$/, '').trim();
81
+ found.push({ kind: 'wikilink', from, to, target: name, label, embed, parameter: hasParameterReference(name) });
80
82
  }
81
83
  const inWikilink = (span) => wikilinks.some((link) => span.from < link.to && span.to > link.from);
82
84
  const visit = (node, inCallout) => {
@@ -84,6 +86,16 @@ export function analyze(text) {
84
86
  const children = node.children ?? [];
85
87
  if (span && !inComment(span.from)) {
86
88
  switch (node.type) {
89
+ case 'text': {
90
+ // A parameter is written in text, and only there (§7.14): code, math, raw HTML and a
91
+ // destination are not text nodes, and an autolink's text is its address.
92
+ for (const reference of parameterReferences(text.slice(span.from, span.to))) {
93
+ const from = span.from + reference.from;
94
+ if (!inComment(from))
95
+ found.push({ kind: 'parameter', from, to: span.from + reference.to, name: reference.name });
96
+ }
97
+ break;
98
+ }
87
99
  case 'heading': {
88
100
  const line = text.slice(span.from, span.to);
89
101
  const marker = /^#{1,6}(?:[ \t]+|$)/.exec(line);
@@ -126,9 +138,15 @@ export function analyze(text) {
126
138
  break;
127
139
  }
128
140
  case 'link': {
141
+ const raw = text.slice(span.from, span.to);
142
+ // An autolink is its address, which writes no parameter.
143
+ if (!raw.startsWith('[')) {
144
+ if (!inWikilink(span))
145
+ found.push({ kind: 'link', ...span, label: null, url: node.url ?? '' });
146
+ return;
147
+ }
129
148
  if (inWikilink(span))
130
149
  break;
131
- const raw = text.slice(span.from, span.to);
132
150
  const first = children[0] && offsets(children[0]);
133
151
  const last = children[children.length - 1] && offsets(children[children.length - 1]);
134
152
  const label = raw.startsWith('[') && first && last ? { from: first.from, to: last.to } : null;
@@ -215,7 +233,8 @@ export function analyze(text) {
215
233
  case 'paragraph': {
216
234
  const raw = text.slice(span.from, span.to);
217
235
  const embed = EMBED_LINE.exec(raw.trim());
218
- if (embed && !raw.includes('\n') && !inCallout && span.from === text.lastIndexOf('\n', span.from - 1) + 1) {
236
+ // An embed of a parameter transcludes nothing (§7.14): it is drawn as a wikilink is.
237
+ if (embed && !hasParameterReference(embed[1]) && !raw.includes('\n') && !inCallout && span.from === text.lastIndexOf('\n', span.from - 1) + 1) {
219
238
  found.push({ kind: 'embed', ...span, target: embed[1].trim(), anchor: embed[2]?.trim() ?? null });
220
239
  return;
221
240
  }
@@ -12,10 +12,10 @@ import { ChangeSet } from '@codemirror/state';
12
12
  import { useEffect, useRef, useState } from 'react';
13
13
  import { useHost } from '../host.js';
14
14
  import { Markdown } from '../Markdown.js';
15
- import { hideComments, resolveWikilinks } from '../markdown.js';
15
+ import { hideComments, resolveWikilinks } from '../source.js';
16
16
  import { isTrue, readProperties } from '../properties.js';
17
17
  import { Transclusion } from '../Transclusion.js';
18
- import { splitEmbeds } from '../transclusion.js';
18
+ import { splitEmbeds } from '../embeds.js';
19
19
  import { wikilinkAddress } from '../wikilink-address.js';
20
20
  import { ICON_OWN_SIZE, ICON_RATIO_FREE, ICON_RATIO_LOCKED, ICON_RESIZE } from '../mode-icons.js';
21
21
  import { describeImage, MAX_IMAGE_WIDTH, readImageSize, resizeImage } from './image-size.js';
package/dist/edit/live.js CHANGED
@@ -640,6 +640,20 @@ function build(state) {
640
640
  break;
641
641
  }
642
642
  case 'wikilink': {
643
+ // A target that writes a parameter leads nowhere until a notebook is created from the model
644
+ // (§7.14): its label is drawn, and there is nothing to follow.
645
+ if (construct.parameter) {
646
+ out.push(mark('cm-ms-wikilink cm-ms-wikilink-parameter', { title: host.strings.parameterLink }).range(construct.label.from, construct.label.to));
647
+ if (touches(from, to)) {
648
+ out.push(syntax.range(from, construct.label.from));
649
+ out.push(syntax.range(construct.label.to, to));
650
+ }
651
+ else {
652
+ out.push(hide.range(from, construct.label.from));
653
+ out.push(hide.range(construct.label.to, to));
654
+ }
655
+ break;
656
+ }
643
657
  const pending = host.reaches(construct.target) === 0 && !host.keeps(construct.target);
644
658
  if (construct.embed && host.keeps(construct.target) && !touches(from, to)) {
645
659
  const source = text.slice(from, to);
@@ -727,6 +741,10 @@ function build(state) {
727
741
  case 'blockId':
728
742
  out.push(mark('cm-ms-block-id').range(from, to));
729
743
  break;
744
+ case 'parameter':
745
+ // A decoration over the characters, which stay text the author edits (§7.14).
746
+ out.push(mark('cm-ms-parameter', { title: host.strings.parameter, 'data-parameter': construct.name }).range(from, to));
747
+ break;
730
748
  case 'html':
731
749
  case 'definition':
732
750
  out.push(mark('cm-ms-raw').range(from, to));
@@ -16,7 +16,8 @@
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 { codeRegions, fenceRegions, headingKey, insideCode, insideTable, outsideCode, tableRegions } from './markdown.js';
19
+ import { hasParameterReference } from './parameters.js';
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;
22
23
  /**
@@ -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/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { ENGLISH, type EditorWords, type NoteStrings, type NoteStringsInput } fr
7
7
  export { customPropertyOf, DEFAULT_THEME, defineTheme, THEME_PROPERTIES, THEME_SLOTS, type BlockquoteSlotProps, type CalloutSlotProps, type CodeBlockSlotProps, type DiagramSlotProps, type EmbedSlotProps, type FootnotesSlotProps, type HeadingSlotProps, type InlineCodeSlotProps, type ModeSwitchSlotProps, type AttachmentSlotProps, type PropertiesSlotProps, type Scheme, type TableSlotProps, type TaskBoxSlotProps, type Theme, type ThemeComponents, type ThemeProperties, type WikilinkSlotProps, } from './theme.js';
8
8
  export { followable } from './address.js';
9
9
  export { readDimensions, readImageAlt, writeDimensions, type Dimensions, type ImageAlt } from './image-dimensions.js';
10
- export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilinks, splitFrontmatter, tableRegions, toUnixNewlines, type SplitDocument, } from './markdown.js';
10
+ export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilinks, splitFrontmatter, tableRegions, toUnixNewlines, type SplitDocument, } from './source.js';
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';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { ENGLISH } from './strings.js';
5
5
  export { customPropertyOf, DEFAULT_THEME, defineTheme, THEME_PROPERTIES, THEME_SLOTS, } from './theme.js';
6
6
  export { followable } from './address.js';
7
7
  export { readDimensions, readImageAlt, writeDimensions } from './image-dimensions.js';
8
- export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilinks, splitFrontmatter, tableRegions, toUnixNewlines, } from './markdown.js';
8
+ export { codeRegions, fenceRegions, headingKey, remoteImageHosts, resolveWikilinks, splitFrontmatter, tableRegions, toUnixNewlines, } from './source.js';
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';
@@ -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,
@@ -8,7 +8,7 @@
8
8
  * before it is parsed is how a notation starts firing inside examples.
9
9
  *
10
10
  * Comments (§7.6) are the one exception, and they are taken out before the
11
- * parser by `hideComments` (`markdown.ts`), which finds code first: a comment
11
+ * parser by `hideComments` (`source.ts`), which finds code first: a comment
12
12
  * may hold markup and blank lines, and once parsed it is spread over nodes no
13
13
  * plugin on a run of text can see whole.
14
14
  *
@@ -8,7 +8,7 @@
8
8
  * before it is parsed is how a notation starts firing inside examples.
9
9
  *
10
10
  * Comments (§7.6) are the one exception, and they are taken out before the
11
- * parser by `hideComments` (`markdown.ts`), which finds code first: a comment
11
+ * parser by `hideComments` (`source.ts`), which finds code first: a comment
12
12
  * may hold markup and blank lines, and once parsed it is spread over nodes no
13
13
  * plugin on a run of text can see whole.
14
14
  *
@@ -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
@@ -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
@@ -23,6 +23,10 @@ export interface NoteStrings {
23
23
  readonly pendingLink: string;
24
24
  /** The title of an address the surface does not follow. */
25
25
  readonly refusedLink: string;
26
+ /** The title of a parameter reference, `{{name}}`, which a notebook created from the model fills in (§7.14). */
27
+ readonly parameter: string;
28
+ /** The title of a wikilink whose target writes a parameter, which leads nowhere until then. */
29
+ readonly parameterLink: string;
26
30
  /** The title of an embed naming a file the notebook does not keep. */
27
31
  readonly attachmentMissing: string;
28
32
  /** 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,8 @@ 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.',
42
44
  attachmentMissing: 'This notebook keeps no file under that name.',
43
45
  attachmentOpen: 'Open',
44
46
  attachmentDownload: 'Download',
package/dist/tasklist.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * by design, because it flattens lists for display, and rebuilding the
12
12
  * document from it would hand the notebook a file nobody typed.
13
13
  */
14
- import { commentRegions, fenceRegions } from './markdown.js';
14
+ import { commentRegions, fenceRegions } from './source.js';
15
15
  /**
16
16
  * A task item, as GFM defines it, at the start of a list item — after any
17
17
  * block quote markers in front of it, because a callout is a block quote and a
package/dist/theme.d.ts CHANGED
@@ -39,6 +39,7 @@ export interface ThemeProperties {
39
39
  readonly textSoft?: string;
40
40
  readonly accent?: string;
41
41
  readonly pending?: string;
42
+ readonly parameter?: string;
42
43
  readonly codeBg?: string;
43
44
  readonly codeColor?: string;
44
45
  readonly codeBorder?: string;
package/dist/theme.js CHANGED
@@ -22,7 +22,7 @@
22
22
  */
23
23
  /** The names of `ThemeProperties`, in the order the documentation lists them. */
24
24
  export const THEME_PROPERTIES = Object.keys({
25
- bg: 1, surface: 1, border: 1, text: 1, textSoft: 1, accent: 1, pending: 1,
25
+ bg: 1, surface: 1, border: 1, text: 1, textSoft: 1, accent: 1, pending: 1, parameter: 1,
26
26
  codeBg: 1, codeColor: 1, codeBorder: 1, inlineCodeBg: 1, inlineCodePadding: 1,
27
27
  tokenKeyword: 1, tokenString: 1, tokenNumber: 1, tokenComment: 1, tokenPunctuation: 1,
28
28
  calloutInfo: 1, calloutIdea: 1, calloutDone: 1, calloutWarn: 1, calloutStop: 1, calloutAside: 1, calloutQuote: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memorysmithapp/markdown-renderer",
3
- "version": "0.8.4",
3
+ "version": "0.9.0",
4
4
  "description": "A React component that draws a MemorySmith note exactly as MemorySmith's reading page does.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -70,6 +70,7 @@
70
70
  "@codemirror/view": "6.43.13",
71
71
  "hast-util-to-jsx-runtime": "2.3.6",
72
72
  "mermaid": "11.17.0",
73
+ "micromark-util-decode-string": "2.0.1",
73
74
  "react-markdown": "9.1.0",
74
75
  "refractor": "5.0.0",
75
76
  "rehype-katex": "7.0.1",
@@ -79,7 +80,7 @@
79
80
  "unified": "11.0.5"
80
81
  },
81
82
  "devDependencies": {
82
- "@memorysmithapp/markdown-spec": "0.8.4",
83
+ "@memorysmithapp/markdown-spec": "0.9.0",
83
84
  "@types/hast": "3.0.5",
84
85
  "@types/react": "19.2.18",
85
86
  "@types/react-dom": "19.2.4",
package/theme-default.css CHANGED
@@ -33,6 +33,9 @@
33
33
  --ms-text-soft: var(--markdown-text-soft, #545d73);
34
34
  --ms-accent: var(--markdown-accent, #0f56d7);
35
35
  --ms-pending: var(--markdown-pending, #a6ab9f);
36
+ /* A parameter of a model, the violet of an aside: distinct from a link's
37
+ blue and a pending link's grey, and its text holds 5:1 on its own tint. */
38
+ --ms-parameter: var(--markdown-parameter, 109, 40, 217);
36
39
  --ms-code-bg: var(--markdown-code-bg, #f4f5f2);
37
40
  /* Muted, as the default theme sets inline code: the soft text of the
38
41
  surface. Inline code has no fill, so it sits on the paper or on the tint
@@ -165,6 +168,7 @@
165
168
  --ms-text-soft: var(--markdown-text-soft, #93a0ba);
166
169
  --ms-accent: var(--markdown-accent, #4c8dff);
167
170
  --ms-pending: var(--markdown-pending, #5d6880);
171
+ --ms-parameter: var(--markdown-parameter, 167, 139, 250);
168
172
  --ms-code-bg: var(--markdown-code-bg, #0e1728);
169
173
  --ms-token-keyword: var(--markdown-token-keyword, #4c8dff);
170
174
  --ms-token-string: var(--markdown-token-string, #f0a05a);
@@ -732,6 +736,28 @@
732
736
  cursor: pointer;
733
737
  }
734
738
 
739
+ /* A parameter of a model, `{{name}}` (§7.14): drawn as what it is, a place a
740
+ value goes, and never as broken text. The braces stay, so what is copied is
741
+ what was typed. A wikilink to one leads nowhere yet, so it is not a link. */
742
+ .markdown .parameter {
743
+ color: rgb(var(--ms-parameter));
744
+ background: rgba(var(--ms-parameter), 0.12);
745
+ border-radius: 4px;
746
+ padding: 0 0.2em;
747
+ font-weight: 500;
748
+ -webkit-box-decoration-break: clone;
749
+ box-decoration-break: clone;
750
+ }
751
+ .markdown .wikilink-parameter {
752
+ font-weight: 600;
753
+ cursor: default;
754
+ }
755
+ /* Marked, it takes the mark's ink: the parameter's violet on the mark's yellow
756
+ holds no contrast in the dark. Its tint still says what it is. */
757
+ .markdown mark .parameter {
758
+ color: inherit;
759
+ }
760
+
735
761
  /* The choice a link to several notes opens. A dialog opened with showModal()
736
762
  lives in the top layer, which no ancestor clips and no stacking context
737
763
  reaches; it is still under `.markdown` in the document, so it takes the
@@ -1818,6 +1844,16 @@
1818
1844
  color: var(--ms-pending);
1819
1845
  border-bottom: 1px dashed var(--ms-pending);
1820
1846
  }
1847
+ .markdown .cm-ms-parameter,
1848
+ .markdown .cm-ms-wikilink.cm-ms-wikilink-parameter {
1849
+ /* A link to a parameter leads nowhere yet: it takes the parameter's colour,
1850
+ as on the page, and not a link's. */
1851
+ color: rgb(var(--ms-parameter));
1852
+ }
1853
+ .markdown .cm-ms-parameter {
1854
+ background: rgba(var(--ms-parameter), 0.12);
1855
+ border-radius: 4px;
1856
+ }
1821
1857
  .markdown .cm-ms-bullet {
1822
1858
  display: inline-block;
1823
1859
  width: 1em;
File without changes
File without changes