barmark 0.19.1 → 0.20.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/CHANGELOG.md +22 -1
- package/dist/chart/direction.js +25 -0
- package/dist/chart/expand.js +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,26 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.20.0] - 2026-11-08
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **`->` cuts the replay's last bar as written** (Kevin's decision,
|
|
17
|
+
2026-11-08, grammar 6). It used to cut the last bar played, so a
|
|
18
|
+
`Fine` or `To Coda` that stopped the replay early, after the jump, cut
|
|
19
|
+
a bar before the stop instead: `## Intro` holding `| E7 | Fine |`,
|
|
20
|
+
replayed as `## Intro ->` after a `D.S. al Fine`, played nothing. Now
|
|
21
|
+
the cut bar is the last one written in the replayed section (from the
|
|
22
|
+
last pass with `x N`); when play stops before it, it is never reached,
|
|
23
|
+
the replay plays up to the stop and its occurrence's `elided` is false.
|
|
24
|
+
- **A `Coda` with no bar after it is an error** (Kevin's decision,
|
|
25
|
+
2026-11-08, grammar 5.2): "Coda has no bar after it, so To Coda has
|
|
26
|
+
nowhere to go on", on the `Coda`'s line. The `Coda` an `al Coda` goes
|
|
27
|
+
on needs a bar after it: a bar written later in the chart, or a later
|
|
28
|
+
heading that replays one (`## Chorus` alone, the last chorus as the
|
|
29
|
+
coda). Like every direction error, it drops the jump. Before, such a chart parsed cleanly and played
|
|
30
|
+
nothing after `To Coda`.
|
|
31
|
+
|
|
12
32
|
## [0.19.1] - 2026-11-07
|
|
13
33
|
|
|
14
34
|
### Fixed
|
|
@@ -590,7 +610,8 @@ The first working release: the reference parser and printer for the
|
|
|
590
610
|
|
|
591
611
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
592
612
|
|
|
593
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
613
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.20.0...HEAD
|
|
614
|
+
[0.20.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.1...barmark-v0.20.0
|
|
594
615
|
[0.19.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.0...barmark-v0.19.1
|
|
595
616
|
[0.19.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.18.0...barmark-v0.19.0
|
|
596
617
|
[0.18.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.17.1...barmark-v0.18.0
|
package/dist/chart/direction.js
CHANGED
|
@@ -61,6 +61,27 @@ function missingMarks(jump, plan, first) {
|
|
|
61
61
|
const name = printDirection(jump.direction);
|
|
62
62
|
return wants.filter(([missing]) => missing).map(([, what]) => `${name} has ${what}`);
|
|
63
63
|
}
|
|
64
|
+
const writes = (l) => l.kind === "bars" || l.kind === "invalid";
|
|
65
|
+
/** Whether the section heading at `i` is a replay: no bar line before the next heading. */
|
|
66
|
+
function isReplay(lines, i) {
|
|
67
|
+
const next = lines.findIndex((l, k) => k > i && l.kind === "section");
|
|
68
|
+
return !lines.slice(i + 1, next < 0 ? undefined : next).some(writes);
|
|
69
|
+
}
|
|
70
|
+
/** Whether a bar follows `m`: on its line, on a later one, or in a later replay (grammar 5.2). */
|
|
71
|
+
function barAfter(lines, m) {
|
|
72
|
+
return lines.some((l, i) => {
|
|
73
|
+
if (l.line < m.line)
|
|
74
|
+
return false;
|
|
75
|
+
if (l.kind === "section")
|
|
76
|
+
return l.line > m.line && isReplay(lines, i);
|
|
77
|
+
if (l.kind === "invalid")
|
|
78
|
+
return l.line > m.line && l.written > 0;
|
|
79
|
+
if (l.kind !== "bars")
|
|
80
|
+
return false;
|
|
81
|
+
const cells = l.line === m.line ? l.cells.slice(m.cell + 1) : l.cells;
|
|
82
|
+
return cells.some((c) => c.kind === "slots" || c.kind === "simile");
|
|
83
|
+
});
|
|
84
|
+
}
|
|
64
85
|
/** The marks no jump uses: each is an error. */
|
|
65
86
|
function unusedMarks(plan, first) {
|
|
66
87
|
const used = {
|
|
@@ -91,6 +112,10 @@ export function planJump(lines, error) {
|
|
|
91
112
|
const plan = jump?.direction.kind === "jump" ? jump.direction : null;
|
|
92
113
|
if (jump && plan)
|
|
93
114
|
problems.push(...missingMarks(jump, plan, first).map((m) => [jump, m]));
|
|
115
|
+
const coda = first.get("coda");
|
|
116
|
+
// Only the Coda an al Coda goes on; an unused one is an error of its own.
|
|
117
|
+
if (coda && plan?.al === "coda" && !barAfter(lines, coda))
|
|
118
|
+
problems.push([coda, "Coda has no bar after it, so To Coda has nowhere to go on"]);
|
|
94
119
|
for (const m of unusedMarks(plan, first))
|
|
95
120
|
problems.push([m, `${printDirection(m.direction)}: no jump uses it`]);
|
|
96
121
|
for (const [m, message] of problems)
|
package/dist/chart/expand.js
CHANGED
|
@@ -424,6 +424,12 @@ sing) {
|
|
|
424
424
|
times(h.repeat, h.line, out, (into) => playItems(itemsOf.get(s) ?? [], into));
|
|
425
425
|
return { replayOf: null, elided: false };
|
|
426
426
|
};
|
|
427
|
+
/** Whether `out` ends with the last bar written in `s` (grammar 6: what `->` cuts). */
|
|
428
|
+
const reachesEnd = (s, out) => {
|
|
429
|
+
const bars = s.lines.flatMap((l) => (l.kind === "bars" ? (resolved.get(l) ?? []) : []));
|
|
430
|
+
const last = bars.findLast((p) => p.kind === "bar");
|
|
431
|
+
return last?.kind === "bar" && flattenBars(out).at(-1)?.written === last.written;
|
|
432
|
+
};
|
|
427
433
|
/** A replay's bars into `out`, then its own lines; null when it replays nothing. */
|
|
428
434
|
const playReplay = (s, h, out) => {
|
|
429
435
|
// A nameless heading is already an error; it has nothing to replay.
|
|
@@ -437,7 +443,8 @@ sing) {
|
|
|
437
443
|
where.replay = h.line;
|
|
438
444
|
times(h.repeat, h.line, out, (into) => playItems(itemsOf.get(source) ?? [], into));
|
|
439
445
|
where.replay = null;
|
|
440
|
-
|
|
446
|
+
// It cuts the last bar as written; play stopped before it (a Fine, a To Coda) never reaches it.
|
|
447
|
+
const elided = h.elided && reachesEnd(source, out) && removeLastBar(out);
|
|
441
448
|
// A replay heading stands for its bars: its own lines (directives) come after them.
|
|
442
449
|
playItems(itemsOf.get(s) ?? [], out);
|
|
443
450
|
return { replayOf: source.heading.line, elided };
|