@barmark/render 0.9.0 → 0.9.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,18 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.1] - 2026-11-03
10
+
11
+ ### Fixed
12
+
13
+ - **Bar numbers count the bars as written** (issue #92), each once, as a
14
+ band counts them and as `PlayedBar.written` gives them. Before, the
15
+ margin counted played bars, so a second ending or anything after a
16
+ repeat or a jump numbered past the printed score. A replayed section
17
+ now shows the numbers it was written with; the coda after a
18
+ `D.S. al Coda`, and bars after an open repeat, are numbered instead
19
+ of left blank. Screen readers hear the same numbers.
20
+
9
21
  ## [0.9.0] - 2026-11-03
10
22
 
11
23
  ### Added
@@ -256,7 +268,8 @@ that needs no script or as the `<barmark-chart>` web component. Requires
256
268
  zoom without sideways scrolling, the element renders and re-renders, and
257
269
  a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
258
270
 
259
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.9.0...HEAD
271
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.9.1...HEAD
272
+ [0.9.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.9.0...render-v0.9.1
260
273
  [0.9.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.8.0...render-v0.9.0
261
274
  [0.8.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.7.3...render-v0.8.0
262
275
  [0.7.3]: https://github.com/kevinpeckham/barmark/compare/render-v0.7.2...render-v0.7.3
package/README.md CHANGED
@@ -178,8 +178,10 @@ At the default size chords are 16px and no label is under 12px.
178
178
 
179
179
  Chords appear in their canonical form whatever the author typed (`Cø`
180
180
  shows as Cm⁷(♭5)). `%` is drawn as the bar it copies; a replayed section
181
- is drawn in full with its own bar numbers, and its own lyrics replace the
182
- written section's. A line with an error shows as written, underlined,
181
+ is drawn in full, and its own lyrics replace the written section's. Bar
182
+ numbers count the bars as written, each once, as a band counts them: a
183
+ repeat, an ending, a jump or a replay doesn't move them, so a replayed
184
+ section shows the numbers it was written with. A line with an error shows as written, underlined,
183
185
  with its message. `layoutChart(text)` returns all of this as data, if
184
186
  you want to draw it yourself.
185
187
 
package/dist/model.js CHANGED
@@ -13,7 +13,6 @@ export function layoutChart(text, options = {}) {
13
13
  parse,
14
14
  source: text.split(/\r?\n/),
15
15
  errors: errorsByLine(parse),
16
- lastKnownBar: lastKnownBar(parse.events),
17
16
  written: new Map(groups.flatMap((g) => (g.heading ? [[g.heading.line, g]] : []))),
18
17
  };
19
18
  const blocks = groups.map((g) => layoutGroup(g, ctx));
@@ -44,27 +43,6 @@ function errorsByLine(parse) {
44
43
  }
45
44
  return errors;
46
45
  }
47
- /** The count of bars up to the end of the first open repeat (all of them if there is none). */
48
- function lastKnownBar(events) {
49
- let count = 0;
50
- const countBars = (es) => {
51
- for (const e of es) {
52
- if (e.kind === "bar")
53
- count++;
54
- else if (e.kind === "open")
55
- countBars(e.events);
56
- }
57
- };
58
- for (const e of events) {
59
- if (e.kind === "open") {
60
- countBars(e.events);
61
- return count;
62
- }
63
- if (e.kind === "bar")
64
- count++;
65
- }
66
- return Number.POSITIVE_INFINITY;
67
- }
68
46
  /** The title line, and the directives before any other content, form the header. */
69
47
  function splitHeader(lines) {
70
48
  const header = {};
@@ -226,11 +204,11 @@ function layoutRow(l, played, previous, ctx) {
226
204
  prev = model;
227
205
  cells.push(model);
228
206
  }
229
- const firstIndex = played[0]?.index;
230
207
  return {
231
208
  kind: "row",
232
209
  line: l.line,
233
- barNumber: firstIndex !== undefined && firstIndex <= ctx.lastKnownBar ? firstIndex : null,
210
+ // Numbered as written, as a band counts (issue #92): repeats, endings, jumps and replays don't move it.
211
+ barNumber: (played[0] ?? written[0])?.written ?? null,
234
212
  opens: l.opens,
235
213
  closes: l.closes,
236
214
  repeat: l.repeat,
package/dist/types.d.ts CHANGED
@@ -25,7 +25,7 @@ export type SectionBlock = {
25
25
  export type BlockItem = {
26
26
  kind: "row";
27
27
  line: number;
28
- /** The play-order number of the row's first bar on its first pass. */
28
+ /** The written number of the row's first bar (`PlayedBar.written`); a replay shows its section's numbers. Null for a row with no bar. */
29
29
  barNumber: number | null;
30
30
  opens: boolean;
31
31
  closes: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/render",
3
- "version": "0.9.0",
3
+ "version": "0.9.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": {