@barmark/render 0.21.0 → 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,14 @@ 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
+
9
17
  ## [0.21.0] - 2026-11-19
10
18
 
11
19
  ### Added
@@ -591,7 +599,8 @@ that needs no script or as the `<barmark-chart>` web component. Requires
591
599
  zoom without sideways scrolling, the element renders and re-renders, and
592
600
  a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
593
601
 
594
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.0...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
595
604
  [0.21.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.2...render-v0.21.0
596
605
  [0.20.2]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.1...render-v0.20.2
597
606
  [0.20.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.20.0...render-v0.20.1
package/README.md CHANGED
@@ -83,7 +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 `?`. 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
+ | `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 |
87
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"` |
88
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 |
89
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/model.js CHANGED
@@ -296,7 +296,7 @@ function layoutSystemOf(written, occurrence, previous, ctx) {
296
296
  const [only] = lines;
297
297
  if (only && lines.length === 1 && loneBare(only, ctx)) {
298
298
  ctx.changed = true;
299
- return layoutOne(only, occurrence, previous, ctx);
299
+ return layoutOne(only, occurrence, previous, ctx, leftOutSingers(written, lines, ctx));
300
300
  }
301
301
  return layoutSystemAt(lines, written, occurrence, previous, ctx);
302
302
  }
@@ -305,6 +305,13 @@ const loneBare = (l, ctx) => ctx.parse.parts.length === 1 &&
305
305
  ctx.parse.parts[0]?.sings !== undefined &&
306
306
  l.lineName === undefined &&
307
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
+ }
308
315
  /** A line with a problem the grid draws where it is written: as written, or on its unreadable slots. */
309
316
  const flawed = (l, ctx) => ctx.errors.has(l.line) || ctx.unread.has(l.line);
310
317
  const sings = (l, ctx) => l.kind === "bars" && singerOf(l, ctx.parse) !== null;
@@ -349,14 +356,14 @@ function withoutMelody(lines, ctx) {
349
356
  /** A system, and the words under it that no line in it sings; `written` is every line the system writes, drawn or not. */
350
357
  function layoutSystemAt(lines, written, occurrence, previous, ctx) {
351
358
  const item = layoutSystem(lines, written, occurrence, previous, ctx);
352
- const lyrics = lyricRows(lines, occurrence, ctx);
359
+ const lyrics = lyricRows(lines, occurrence, ctx, leftOutSingers(written, lines, ctx));
353
360
  // The words go under the system: in its last row that plays.
354
361
  const last = item.rows.findLastIndex((p) => p.row.kind === "row" && !p.row.cells.some(isTacet));
355
362
  const rows = item.rows.map((p, i) => i === last && p.row.kind === "row" && lyrics.length ? { ...p, row: { ...p.row, lyrics } } : p);
356
363
  return { items: [{ ...item, rows }], previous: lastOfSystem(item) ?? previous };
357
364
  }
358
365
  /** A line outside a system: as written when it has an error; a bar line with the words under it. */
359
- function layoutOne(l, occurrence, previous, ctx) {
366
+ function layoutOne(l, occurrence, previous, ctx, leftOut = new Set()) {
360
367
  if (ctx.errors.has(l.line))
361
368
  return { items: [errorItem(l.line, ctx)], previous };
362
369
  const item = layoutLine(l, occurrence, previous, ctx);
@@ -364,7 +371,7 @@ function layoutOne(l, occurrence, previous, ctx) {
364
371
  return { items: [], previous };
365
372
  if (item.kind !== "row" || l.kind !== "bars")
366
373
  return { items: [item], previous };
367
- const lyrics = lyricRows([l], occurrence, ctx);
374
+ const lyrics = lyricRows([l], occurrence, ctx, leftOut);
368
375
  const row = lyrics.length ? { ...item, lyrics } : item;
369
376
  return { items: [row], previous: lastSlots(item.cells) ?? previous };
370
377
  }
@@ -384,14 +391,14 @@ function landingsOn(l, played, ctx) {
384
391
  * The words under a row or system that no line in it sings under its
385
392
  * slots (barmark's grammar 7.7): a lyric row on no melody, spaced by beat.
386
393
  */
387
- function lyricRows(lines, occurrence, ctx) {
394
+ function lyricRows(lines, occurrence, ctx, leftOut) {
388
395
  const drawn = lines.filter((l) => l.kind === "bars" && !ctx.errors.has(l.line));
389
396
  const ref = drawn[0];
390
397
  if (!ref)
391
398
  return [];
392
399
  const sung = new Set(drawn.flatMap((l) => singerOf(l, ctx.parse) ?? []));
393
400
  const lands = landingsOn(ref, playedOn(ref.line, occurrence, ctx), ctx);
394
- return rowVerses(lands, sung);
401
+ return rowVerses(lands, sung, leftOut);
395
402
  }
396
403
  const systemOf = (l) => (l?.kind === "bars" || l?.kind === "invalid") && l.system !== undefined ? l.system : null;
397
404
  /** The lines of the system that starts at `i`. */
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.21.0",
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": {