@barmark/render 0.20.2 → 0.21.1

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/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.21.1] - 2026-11-19
10
+
11
+ ### Changed
12
+
13
+ - **With `melody: false`, a melisma's held place is not drawn**: the words
14
+ of a left-out melody take the space they would with no melody written,
15
+ so `maz- / ing_/` draws as `maz- / ing`, with no extender.
16
+
17
+ ## [0.21.0] - 2026-11-19
18
+
19
+ ### Added
20
+
21
+ - **`melody: false`** (attribute `melody="off"`, property `melody`) leaves a
22
+ voice part's singing line out of the grid, so a lead sheet of chords,
23
+ melody and words draws as chords and words. The words stay, spaced by
24
+ beat under the chords. The melody is left out only beside a line that
25
+ draws its bars; a melody on its own stays, a line with a problem stays
26
+ so the grid still shows where the problem is, and a singing line that
27
+ writes chord names, `N.C.` or `?` (or a `%` copying one) stays; nothing
28
+ musical changes.
29
+
9
30
  ## [0.20.2] - 2026-11-19
10
31
 
11
32
  ### Changed
@@ -578,7 +599,9 @@ that needs no script or as the `<barmark-chart>` web component. Requires
578
599
  zoom without sideways scrolling, the element renders and re-renders, and
579
600
  a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
580
601
 
581
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.2...HEAD
602
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.1...HEAD
603
+ [0.21.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.0...render-v0.21.1
604
+ [0.21.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.2...render-v0.21.0
582
605
  [0.20.2]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.1...render-v0.20.2
583
606
  [0.20.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.0...render-v0.20.1
584
607
  [0.20.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.19.1...render-v0.20.0
package/README.md CHANGED
@@ -53,7 +53,7 @@ whenever one changes; it fetches a `src` once, and renders once however
53
53
  many properties and attributes change together. A chart rendered on the
54
54
  server by `renderChart` keeps its music until it has a source of its own,
55
55
  and still follows `theme`, `bar-numbers`, `wrap` and `columns`; a change to
56
- `numerals`, `rehearsal-letters`, `show-part`, `chord-diagrams` or
56
+ `numerals`, `rehearsal-letters`, `melody`, `show-part`, `chord-diagrams` or
57
57
  `diagram-hand` needs the chart's text, so it waits for a source.
58
58
 
59
59
  For a live editor, set `text`:
@@ -83,6 +83,7 @@ the element loads, with `<style data-barmark-font>` holding
83
83
  | `rehearsalLetters` | `rehearsal-letters` (`rehearsalLetters`) | `false` | boxed A, B, C… on each section as played; none when the chart writes a rehearsal mark of its own (below) |
84
84
  | `numerals` | `numerals` (`numerals`) | none | `"nashville"` (6m⁷) or `"roman"` (vi⁷): each chord as its degree in its bar's key |
85
85
  | `wrap` | `wrap="off"` (`wrap`) | `true` | wrap a section's rows when it is wider than the chart's box; off, rows keep their columns and the chart overflows, for its page to scroll |
86
+ | `melody` | `melody="off"` (`melody`) | `true` | `false` leaves a voice part's singing line out of the grid; its words stay, drawn by beat under the chords. The melody is left out only beside a line that draws its bars; a melody on its own stays, and so does a line with a problem or one that writes chord names, `N.C.` or `?`. A melisma's held place is not drawn where the melody is left out, so the words take the space they would with no melody written. In a one-part lead sheet the chord line then draws as a plain row with no label. `@barmark/score`'s score view still shows it |
86
87
  | `columns` | `columns="row"` (`columns`) | `"shared"` | `"shared"`: a section's rows share column tracks, so bar lines line up down the section; `"row"`: each row sizes its own bars (below). Any other value is `"shared"` |
87
88
  | `part` | `show-part` (`showPart`) | none | draw only the part with this label, as one player reads it: tutti bars, its own bars, and "tacet" where it rests. The attribute isn't `part`, which HTML keeps for `::part()` styling |
88
89
  | `chordDiagrams` | `chord-diagrams="guitar"` (`chordDiagrams`) | none | `"guitar"`: a strip of guitar chord diagrams after the header, one for each distinct chord (below). Any other value is off |
package/dist/element.js CHANGED
@@ -20,6 +20,8 @@ export function optionsFromAttributes(el) {
20
20
  barNumbers: el.getAttribute("bar-numbers") !== "off",
21
21
  rehearsalLetters: el.hasAttribute("rehearsal-letters"),
22
22
  wrap: el.getAttribute("wrap") !== "off",
23
+ // Only "off" hides the melody; anything else, or none, leaves it unset.
24
+ ...(el.getAttribute("melody") === "off" ? { melody: false } : {}),
23
25
  ...(numerals ? { numerals } : {}),
24
26
  ...(part ? { part } : {}),
25
27
  ...(diagrams ? { chordDiagrams: "guitar" } : {}),
@@ -66,6 +68,7 @@ function defineElement() {
66
68
  "rehearsal-letters",
67
69
  "numerals",
68
70
  "wrap",
71
+ "melody",
69
72
  "show-part",
70
73
  "columns",
71
74
  "chord-diagrams",
@@ -134,6 +137,15 @@ function defineElement() {
134
137
  else
135
138
  this.setAttribute("wrap", "off");
136
139
  }
140
+ get melody() {
141
+ return optionsFromAttributes(this).melody ?? true;
142
+ }
143
+ set melody(v) {
144
+ if (v)
145
+ this.removeAttribute("melody");
146
+ else
147
+ this.setAttribute("melody", "off");
148
+ }
137
149
  get rehearsalLetters() {
138
150
  return this.hasAttribute("rehearsal-letters");
139
151
  }
package/dist/html.d.ts CHANGED
@@ -21,6 +21,13 @@ export type RenderOptions = {
21
21
  wrap?: boolean;
22
22
  /** Draw only the part with this label (barmark's grammar 7.4): one player's view. */
23
23
  part?: string;
24
+ /**
25
+ * Draw a singer's melody line in the grid (the default). With `false`
26
+ * (the attribute `melody="off"`) it is left out beside a line that draws
27
+ * its bars, its words kept under the chords. A melody on its own stays, and
28
+ * so does a singing line with a problem or with chord names.
29
+ */
30
+ melody?: boolean;
24
31
  /**
25
32
  * How a section sizes its columns. `"shared"` (the default): its rows share
26
33
  * column tracks, so bar lines line up down the section and the widest bar
package/dist/html.js CHANGED
@@ -9,7 +9,7 @@ import { creditsText } from "./credits.js";
9
9
  import { diagramSvg } from "./diagram.js";
10
10
  import { escapeHtml } from "./escape.js";
11
11
  import { fontFaceCss } from "./font.js";
12
- import { isTacet as isTacetCell, layoutChart } from "./model.js";
12
+ import { isTacet as isTacetCell, layoutChart, meloffChanged } from "./model.js";
13
13
  import { barLabel, speakBar, speakDiagram, speakVerses, UNPLAYABLE, VOICING_REPLACED, } from "./speech.js";
14
14
  import { FIT_STEPS, MIN_BAR, stylesheet } from "./styles.js";
15
15
  import { beatLinesHtml, pitchHtml, sungBar, sungSlotHtml, verseNumbersHtml, verseWidth, } from "./verses-html.js";
@@ -25,6 +25,7 @@ function elementAttributes(options) {
25
25
  options.rehearsalLetters ? " rehearsal-letters" : "",
26
26
  numeralsOf(options) ? ` numerals="${numeralsOf(options)}"` : "",
27
27
  options.wrap === false ? ' wrap="off"' : "",
28
+ options.melody === false ? ' melody="off"' : "",
28
29
  options.part ? ` show-part="${escapeHtml(options.part)}"` : "",
29
30
  byRow(options) ? ' columns="row"' : "",
30
31
  diagramAttributes(options),
@@ -53,18 +54,17 @@ function chartHtml(text, options) {
53
54
  const model = layoutChart(text, {
54
55
  rehearsalLetters: options.rehearsalLetters ?? false,
55
56
  ...(options.part && { part: options.part }),
57
+ ...(options.melody === false && { melody: false }),
56
58
  ...(options.chordDiagrams === "guitar" && { chordDiagrams: "guitar" }),
57
59
  });
58
60
  const barNumbers = options.barNumbers ?? true;
59
- const parts = labelled(model);
61
+ const { parts, widest } = gutterOf(model, options);
60
62
  const settings = {
61
63
  barNumbers,
62
64
  gutter: barNumbers || parts,
63
65
  numerals: numeralsOf(options),
64
66
  rows: byRow(options),
65
67
  };
66
- // Every section's left column is as wide as the longest part label, so tutti rows line up with systems.
67
- const widest = Math.max(0, ...model.parts.flatMap(rowLabelsOf).map((l) => l.length));
68
68
  const gutter = parts ? ` data-parts style="--bm-label-chars:${widest}"` : "";
69
69
  return `<div class="bm-chart" data-theme="${themeOf(options)}"${gutter}${layoutAttributes(options, settings)}>${headerHtml(model)}${diagramsHtml(model.diagrams, settings.numerals, handOf(options))}${model.blocks.map((b) => blockHtml(b, settings)).join("")}${copyrightHtml(model)}${options.diagnostics ? diagnosticsHtml(model) : ""}</div>`;
70
70
  }
@@ -72,6 +72,19 @@ function chartHtml(text, options) {
72
72
  const layoutAttributes = (options, settings) => `${settings.barNumbers ? "" : ' data-bar-numbers="off"'}${options.wrap === false ? ' data-wrap="off"' : ""}${settings.rows ? ' data-columns="row"' : ""}`;
73
73
  /** Whether systems have labelled rows: several parts, or one part writing lines (barmark's grammar 7.6). */
74
74
  const labelled = (model) => model.parts.length > 1 || model.parts.some((p) => (p.lines?.length ?? 0) > 0);
75
+ /**
76
+ * Whether rows are labelled, and how wide the longest label is: every
77
+ * section's left column is as wide, so tutti rows line up with systems.
78
+ * Where `melody: false` changed the drawing, only the labels the systems draw count.
79
+ */
80
+ function gutterOf(model, options) {
81
+ const drawn = options.melody === false && meloffChanged(model);
82
+ const labels = drawn ? drawnLabels(model) : model.parts.flatMap(rowLabelsOf);
83
+ const parts = drawn ? labels.length > 0 : labelled(model);
84
+ return { parts, widest: Math.max(0, ...labels.map((l) => l.length)) };
85
+ }
86
+ /** The labels of the system rows the blocks draw. */
87
+ const drawnLabels = (model) => model.blocks.flatMap((b) => b.items.flatMap((i) => (i.kind === "system" ? i.rows.map((r) => r.label) : [])));
75
88
  /** A part's row labels: its own, and one per line it writes (barmark's grammar 7.6). */
76
89
  const rowLabelsOf = (p) => [
77
90
  p.label ?? "",
package/dist/model.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { CellModel, ChartModel, LayoutOptions } from "./types.js";
2
+ export declare const meloffChanged: (model: ChartModel) => boolean;
2
3
  export declare function layoutChart(text: string, options?: LayoutOptions): ChartModel;
3
4
  /** A bar where the part rests, in a system or a part's own view (barmark's grammar 7.4). */
4
5
  export declare const isTacet: (c: CellModel) => boolean;
package/dist/model.js CHANGED
@@ -8,6 +8,9 @@ import { extractPart, parseChart, printedAsWritten, unreadSlots, } from "barmark
8
8
  import { chartDiagrams } from "./diagrams.js";
9
9
  import { tempoBeatOf, tempoBeats } from "./tempo.js";
10
10
  import { landings, rowVerses, singerOf, sungVerses } from "./verses.js";
11
+ /** Models `melody: false` changed the drawing of: the markup sizes its label gutter from the rows drawn only for these. */
12
+ const meloffModels = new WeakSet();
13
+ export const meloffChanged = (model) => meloffModels.has(model);
11
14
  /** Whether a tutti bar's parts play different slots, as `%` or `/` on a tutti line can. */
12
15
  const playedApart = (b, line) => {
13
16
  const own = (b.parts ?? []).filter((p) => p?.line === line).map((p) => JSON.stringify(p?.slots));
@@ -70,12 +73,15 @@ export function layoutChart(text, options = {}) {
70
73
  written: new Map(groups.flatMap((g) => (g.heading ? [[g.heading.line, g]] : []))),
71
74
  bars: indexByLine(barsByLine(parse)),
72
75
  beats: tempoBeats(parse.lines),
76
+ melody: options.melody !== false,
77
+ changed: false,
78
+ melodies: new Map(),
73
79
  };
74
80
  const blocks = groups.map((g) => layoutGroup(g, ctx));
75
81
  // A chart that writes its own rehearsal marks keeps them alone: letters beside them would mark each place twice.
76
82
  if (options.rehearsalLetters && !parse.bars.some((b) => b.rehearsal !== undefined))
77
83
  letterBlocks(blocks);
78
- return {
84
+ const model = {
79
85
  title: parse.title,
80
86
  part: parse.part,
81
87
  parts: parse.parts,
@@ -86,6 +92,9 @@ export function layoutChart(text, options = {}) {
86
92
  diagnostics: parse.diagnostics,
87
93
  diagrams: options.chordDiagrams === "guitar" ? chartDiagrams(blocks, parse) : [],
88
94
  };
95
+ if (ctx.changed)
96
+ meloffModels.add(model);
97
+ return model;
89
98
  }
90
99
  /** The beat the header's tempo counts: its directives' (they share the next bar line), or the default. */
91
100
  function headerBeat(lines, beats) {
@@ -266,23 +275,95 @@ function layoutLines(lines, occurrence, ctx) {
266
275
  continue;
267
276
  const laid = system === null
268
277
  ? layoutOne(l, occurrence, previous, ctx)
269
- : layoutSystemAt(systemLines(lines, i), occurrence, previous, ctx);
278
+ : layoutSystemOf(systemLines(lines, i), occurrence, previous, ctx);
270
279
  previous = laid.previous;
271
280
  items.push(...laid.items);
272
281
  }
273
282
  return items;
274
283
  }
275
- /** A system, and the words under it that no line in it sings. */
276
- function layoutSystemAt(lines, occurrence, previous, ctx) {
277
- const item = layoutSystem(lines, occurrence, previous, ctx);
278
- const lyrics = lyricRows(lines, occurrence, ctx);
284
+ /**
285
+ * A system as drawn: with `melody: false`, its melody lines are left out when
286
+ * a line that does not sing still draws its bars, and their words draw by
287
+ * beat under the rest. In a chart of one singing part, the part's lone bare
288
+ * line draws as a line outside a system does.
289
+ */
290
+ function layoutSystemOf(written, occurrence, previous, ctx) {
291
+ if (ctx.melody)
292
+ return layoutSystemAt(written, written, occurrence, previous, ctx);
293
+ const lines = withoutMelody(written, ctx);
294
+ if (lines.length < written.length)
295
+ ctx.changed = true;
296
+ const [only] = lines;
297
+ if (only && lines.length === 1 && loneBare(only, ctx)) {
298
+ ctx.changed = true;
299
+ return layoutOne(only, occurrence, previous, ctx, leftOutSingers(written, lines, ctx));
300
+ }
301
+ return layoutSystemAt(lines, written, occurrence, previous, ctx);
302
+ }
303
+ /** Whether the line is the bare line of a chart's only part, which has a singing line, and does not sing itself. */
304
+ const loneBare = (l, ctx) => ctx.parse.parts.length === 1 &&
305
+ ctx.parse.parts[0]?.sings !== undefined &&
306
+ l.lineName === undefined &&
307
+ !sings(l, ctx);
308
+ /** The parts whose singing line the system's `written` lines lost to `drawn`: their words draw bare of melisma. */
309
+ function leftOutSingers(written, drawn, ctx) {
310
+ if (written.length === drawn.length)
311
+ return new Set();
312
+ const kept = new Set(drawn);
313
+ return new Set(written.flatMap((l) => l.kind === "bars" && !kept.has(l) ? (singerOf(l, ctx.parse) ?? []) : []));
314
+ }
315
+ /** A line with a problem the grid draws where it is written: as written, or on its unreadable slots. */
316
+ const flawed = (l, ctx) => ctx.errors.has(l.line) || ctx.unread.has(l.line);
317
+ const sings = (l, ctx) => l.kind === "bars" && singerOf(l, ctx.parse) !== null;
318
+ const membersOf = (s) => (s.kind === "group" ? s.members : [s]);
319
+ /** A slot a melody is made of: a hold, a rest, or a note set. */
320
+ const melodic = (s) => membersOf(s).every((m) => m.kind === "hold" || m.kind === "silence" || (m.kind === "chord" && m.chord.kind === "notes"));
321
+ /**
322
+ * Whether every slot of the line, as written and as its bars play, is
323
+ * melodic: a chord name, `N.C.`, `?` or a `%` copying one is not. Read once
324
+ * a line, and each bar's slots once however often it plays: a section's
325
+ * every replay asks.
326
+ */
327
+ function melodyOnly(l, ctx) {
328
+ const known = ctx.melodies.get(l.line);
329
+ if (known !== undefined)
330
+ return known;
331
+ const read = new Set();
332
+ const melodicAll = (slots) => {
333
+ if (read.has(slots))
334
+ return true;
335
+ read.add(slots);
336
+ return slots.every(melodic);
337
+ };
338
+ const only = l.cells.every((c) => c.kind !== "slots" || melodicAll(c.slots)) &&
339
+ barsOn(l.line, ctx).every((b) => melodicAll(b.slots));
340
+ ctx.melodies.set(l.line, only);
341
+ return only;
342
+ }
343
+ /**
344
+ * The system's lines but its melody lines (barmark's grammar 7.7): a singing
345
+ * line with no problem drawn in place whose slots are all notes, holds or
346
+ * rests. They go only when a line that does not sing still draws its bars;
347
+ * else all the lines stay.
348
+ */
349
+ function withoutMelody(lines, ctx) {
350
+ const draws = (l) => l.kind === "bars" && !ctx.errors.has(l.line);
351
+ if (!lines.some((l) => !sings(l, ctx) && draws(l)))
352
+ return lines;
353
+ const melody = (l) => l.kind === "bars" && sings(l, ctx) && !flawed(l, ctx) && melodyOnly(l, ctx);
354
+ return lines.filter((l) => !melody(l));
355
+ }
356
+ /** A system, and the words under it that no line in it sings; `written` is every line the system writes, drawn or not. */
357
+ function layoutSystemAt(lines, written, occurrence, previous, ctx) {
358
+ const item = layoutSystem(lines, written, occurrence, previous, ctx);
359
+ const lyrics = lyricRows(lines, occurrence, ctx, leftOutSingers(written, lines, ctx));
279
360
  // The words go under the system: in its last row that plays.
280
361
  const last = item.rows.findLastIndex((p) => p.row.kind === "row" && !p.row.cells.some(isTacet));
281
362
  const rows = item.rows.map((p, i) => i === last && p.row.kind === "row" && lyrics.length ? { ...p, row: { ...p.row, lyrics } } : p);
282
363
  return { items: [{ ...item, rows }], previous: lastOfSystem(item) ?? previous };
283
364
  }
284
365
  /** A line outside a system: as written when it has an error; a bar line with the words under it. */
285
- function layoutOne(l, occurrence, previous, ctx) {
366
+ function layoutOne(l, occurrence, previous, ctx, leftOut = new Set()) {
286
367
  if (ctx.errors.has(l.line))
287
368
  return { items: [errorItem(l.line, ctx)], previous };
288
369
  const item = layoutLine(l, occurrence, previous, ctx);
@@ -290,7 +371,7 @@ function layoutOne(l, occurrence, previous, ctx) {
290
371
  return { items: [], previous };
291
372
  if (item.kind !== "row" || l.kind !== "bars")
292
373
  return { items: [item], previous };
293
- const lyrics = lyricRows([l], occurrence, ctx);
374
+ const lyrics = lyricRows([l], occurrence, ctx, leftOut);
294
375
  const row = lyrics.length ? { ...item, lyrics } : item;
295
376
  return { items: [row], previous: lastSlots(item.cells) ?? previous };
296
377
  }
@@ -310,14 +391,14 @@ function landingsOn(l, played, ctx) {
310
391
  * The words under a row or system that no line in it sings under its
311
392
  * slots (barmark's grammar 7.7): a lyric row on no melody, spaced by beat.
312
393
  */
313
- function lyricRows(lines, occurrence, ctx) {
394
+ function lyricRows(lines, occurrence, ctx, leftOut) {
314
395
  const drawn = lines.filter((l) => l.kind === "bars" && !ctx.errors.has(l.line));
315
396
  const ref = drawn[0];
316
397
  if (!ref)
317
398
  return [];
318
399
  const sung = new Set(drawn.flatMap((l) => singerOf(l, ctx.parse) ?? []));
319
400
  const lands = landingsOn(ref, playedOn(ref.line, occurrence, ctx), ctx);
320
- return rowVerses(lands, sung);
401
+ return rowVerses(lands, sung, leftOut);
321
402
  }
322
403
  const systemOf = (l) => (l?.kind === "bars" || l?.kind === "invalid") && l.system !== undefined ? l.system : null;
323
404
  /** The lines of the system that starts at `i`. */
@@ -347,7 +428,7 @@ const spokenOf = (p, l) => l.lineName === undefined ? p.name : `${p.name} ${l.li
347
428
  /** A system row's label: the part's, and its line's name (`Pno.RH`). */
348
429
  const labelOf = (l) => `${l.part ?? ""}${l.lineName === undefined ? "" : `.${l.lineName}`}`;
349
430
  /** A row per declared part, or per line it writes, in score order: its own line, its error, or tacet bars. */
350
- function layoutSystem(lines, occurrence, previous, ctx) {
431
+ function layoutSystem(lines, written, occurrence, previous, ctx) {
351
432
  const ref = lines.find((l) => l.kind === "bars" && !ctx.errors.has(l.line));
352
433
  const reference = ref ? layoutRow(ref, playedOn(ref.line, occurrence, ctx), previous, ctx) : null;
353
434
  const ownRow = (own) => ctx.errors.has(own.line) || own.kind !== "bars"
@@ -355,6 +436,9 @@ function layoutSystem(lines, occurrence, previous, ctx) {
355
436
  : layoutRow(own, playedOn(own.line, occurrence, ctx), previous, ctx);
356
437
  const rows = ctx.parse.parts.flatMap((p) => {
357
438
  const own = ownLines(lines, p);
439
+ // A part whose every line was left out has no row; one with no line written is tacet.
440
+ if (!own.length && ownLines(written, p).length)
441
+ return [];
358
442
  if (!own.length)
359
443
  return [
360
444
  { label: p.label ?? "", name: p.name, row: tacetRow(reference, lines[0]?.line ?? 0) },
package/dist/types.d.ts CHANGED
@@ -9,6 +9,13 @@ export type LayoutOptions = {
9
9
  */
10
10
  rehearsalLetters?: boolean;
11
11
  part?: string;
12
+ /**
13
+ * Draw a singer's melody line in the grid (the default, `true`). With
14
+ * `false` it is left out of a system that has another line which draws its
15
+ * bars, and its words draw by beat under the chords. A melody on its own
16
+ * stays; so does a singing line with a problem or with chord names.
17
+ */
18
+ melody?: boolean;
12
19
  /** Give the model a diagram entry for each chord, as a guitar plays it; off when absent. */
13
20
  chordDiagrams?: "guitar";
14
21
  };
package/dist/verses.d.ts CHANGED
@@ -30,6 +30,10 @@ export declare function singerOf(l: BarsLine, parse: ChartParse): string | null;
30
30
  export declare function landings(bars: (PlayedBar | undefined)[], passes: PlayedBar[]): Landing[];
31
31
  /** The verses a singing line's part sings over its bars, each syllable under its slot. */
32
32
  export declare function sungVerses(cells: CellModel[], lands: Landing[], key: string): Verse[];
33
- /** The verses no row sings under its slots: the chart's words, or a singer's with no melody here, by beat. */
34
- export declare function rowVerses(lands: Landing[], sung: Set<string>): Verse[];
33
+ /**
34
+ * The verses no row sings under its slots: the chart's words, or a singer's
35
+ * with no melody here, by beat. A singer in `leftOut` had its melody left
36
+ * out of the system (`melody: false`): its melisma's held places take no step.
37
+ */
38
+ export declare function rowVerses(lands: Landing[], sung: Set<string>, leftOut?: Set<string>): Verse[];
35
39
  export {};
package/dist/verses.js CHANGED
@@ -150,11 +150,12 @@ function stepsFor(fractions) {
150
150
  return n;
151
151
  return MAX_STEPS;
152
152
  }
153
- /** A verse's syllables in a bar on its beats: equal steps, each syllable at its onset's. */
154
- function onBeats(landing, key, verse) {
153
+ /** A verse's syllables in a bar on its beats: equal steps, each syllable at its onset's; with `bare`, a held place is not one. */
154
+ function onBeats(landing, key, verse, bare) {
155
155
  if (!landing)
156
156
  return [];
157
- const sung = verseIn(landing, key, verse);
157
+ const heard = verseIn(landing, key, verse);
158
+ const sung = bare ? heard.filter((s) => s.syllable.kind !== "held") : heard;
158
159
  const length = barLength(landing.bar.meter);
159
160
  const steps = stepsFor(sung.map((s) => s.at / length));
160
161
  const out = Array.from({ length: steps }, () => []);
@@ -162,10 +163,18 @@ function onBeats(landing, key, verse) {
162
163
  out[Math.min(steps - 1, Math.round((s.at / length) * steps))]?.push(s.syllable);
163
164
  return out;
164
165
  }
165
- /** The verses no row sings under its slots: the chart's words, or a singer's with no melody here, by beat. */
166
- export function rowVerses(lands, sung) {
167
- return versesOf(lands, (k) => !sung.has(k)).map(([key, verse]) => ({
166
+ /**
167
+ * The verses no row sings under its slots: the chart's words, or a singer's
168
+ * with no melody here, by beat. A singer in `leftOut` had its melody left
169
+ * out of the system (`melody: false`): its melisma's held places take no step.
170
+ */
171
+ export function rowVerses(lands, sung, leftOut = new Set()) {
172
+ return versesOf(lands, (k) => !sung.has(k))
173
+ .filter(([key, verse]) => !leftOut.has(key) || sounds(lands, key, verse))
174
+ .map(([key, verse]) => ({
168
175
  verse,
169
- cells: lands.map((l) => onBeats(l, key, verse)),
176
+ cells: lands.map((l) => onBeats(l, key, verse, leftOut.has(key))),
170
177
  }));
171
178
  }
179
+ /** Whether a verse has a syllable that is not held somewhere in the row: one that only holds draws nothing bare. */
180
+ const sounds = (lands, key, verse) => lands.some((l) => verseIn(l, key, verse).some((s) => s.syllable.kind !== "held"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/render",
3
- "version": "0.20.2",
3
+ "version": "0.21.1",
4
4
  "description": "Render barmark chord charts as a clean, accessible bar grid: HTML with Declarative Shadow DOM, or the <barmark-chart> web component.",
5
5
  "type": "module",
6
6
  "exports": {