linked-rolls 0.34.0 → 0.35.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/lib/notes.d.ts CHANGED
@@ -4,6 +4,7 @@ export type NotePart = {
4
4
  } | {
5
5
  type: 'reference';
6
6
  id: string;
7
+ label?: string;
7
8
  };
8
9
  /** The note in the pieces it is shown in: stretches of text and what they refer to. */
9
10
  export declare const partsOfNote: (note: string) => NotePart[];
@@ -11,7 +12,8 @@ export declare const partsOfNote: (note: string) => NotePart[];
11
12
  export declare const referencesInNote: (note: string) => string[];
12
13
  /**
13
14
  * The note as it reads, with every reference resolved to the name the
14
- * edition gives that entity. A reference nothing answers to keeps its id,
15
- * so that the gap is visible rather than silent.
15
+ * edition gives that entity, or to the words the note puts in its place.
16
+ * A reference nothing answers to keeps its id, so that the gap is visible
17
+ * rather than silent.
16
18
  */
17
19
  export declare const resolveNote: (note: string, nameOf: (id: string) => string | undefined) => string;
package/lib/notes.js CHANGED
@@ -1,10 +1,15 @@
1
1
  /**
2
- * A note refers to a version or a copy instead of naming it, so that a
3
- * label the stemma decides is never written into the prose. A reference
4
- * reads `{{<id>}}`, where the id is the entity's, and is resolved when
5
- * the note is shown.
2
+ * A note refers to an entity instead of naming it, so that a label the
3
+ * stemma decides is never written into the prose. A reference reads
4
+ * `{{<id>}}`, where the id is the entity's, and is resolved when the note
5
+ * is shown.
6
+ *
7
+ * An entity the edition gives no name to, a perforation or an edit, needs
8
+ * the note's own words to stand in the sentence: `{{<id>|die Stanzung bei
9
+ * 7364,7 mm}}`. The name wins where the edition has one, so a siglum
10
+ * still follows the stemma and a written-out label cannot freeze it.
6
11
  */
7
- const reference = /\{\{\s*([^{}\s]+)\s*\}\}/g;
12
+ const reference = /\{\{\s*([^{}|\s]+)\s*(?:\|([^{}]*))?\}\}/g;
8
13
  /** The note in the pieces it is shown in: stretches of text and what they refer to. */
9
14
  export const partsOfNote = (note) => {
10
15
  const parts = [];
@@ -13,7 +18,8 @@ export const partsOfNote = (note) => {
13
18
  const at = match.index ?? 0;
14
19
  if (at > read)
15
20
  parts.push({ type: 'text', text: note.slice(read, at) });
16
- parts.push({ type: 'reference', id: match[1] });
21
+ const label = match[2]?.trim();
22
+ parts.push({ type: 'reference', id: match[1], ...(label && { label }) });
17
23
  read = at + match[0].length;
18
24
  }
19
25
  if (read < note.length)
@@ -24,9 +30,10 @@ export const partsOfNote = (note) => {
24
30
  export const referencesInNote = (note) => partsOfNote(note).flatMap(part => part.type === 'reference' ? [part.id] : []);
25
31
  /**
26
32
  * The note as it reads, with every reference resolved to the name the
27
- * edition gives that entity. A reference nothing answers to keeps its id,
28
- * so that the gap is visible rather than silent.
33
+ * edition gives that entity, or to the words the note puts in its place.
34
+ * A reference nothing answers to keeps its id, so that the gap is visible
35
+ * rather than silent.
29
36
  */
30
37
  export const resolveNote = (note, nameOf) => partsOfNote(note)
31
- .map(part => part.type === 'text' ? part.text : nameOf(part.id) ?? part.id)
38
+ .map(part => part.type === 'text' ? part.text : nameOf(part.id) ?? part.label ?? part.id)
32
39
  .join('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Digital editions of piano rolls: import, collation, editorial assumptions, JSON-LD export, and emulation through a reproducing system",
5
5
  "license": "MIT",
6
6
  "repository": {