barmark 0.9.0 → 0.10.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 +15 -1
- package/README.md +1 -1
- package/dist/chart/barLine.d.ts +3 -1
- package/dist/chart/barLine.js +11 -2
- package/dist/chart/document.js +1 -1
- package/dist/chart/expand.js +8 -3
- package/dist/chart/types.d.ts +11 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,19 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.10.0] - 2026-11-03
|
|
13
|
+
|
|
14
|
+
Written bar numbers on played bars, issue #70. No chart changes meaning.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **Written bar numbers** (issue #70): every played bar has `written`, its
|
|
19
|
+
number as written, counting each written bar once in written order (`%`
|
|
20
|
+
included, `...` not). A repeat or replay plays its bars under the numbers
|
|
21
|
+
they were written with, so a host can speak a printed score's measure
|
|
22
|
+
numbers. A bar line dropped for an error has `written` too, the bars its
|
|
23
|
+
pipes write, so the numbers after it hold (grammar A.7).
|
|
24
|
+
|
|
12
25
|
## [0.9.0] - 2026-11-02
|
|
13
26
|
|
|
14
27
|
An optional swing amount for `feel:` (`swing 58%`), issue #66. Charts
|
|
@@ -221,7 +234,8 @@ The first working release: the reference parser and printer for the
|
|
|
221
234
|
|
|
222
235
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
223
236
|
|
|
224
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
237
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.10.0...HEAD
|
|
238
|
+
[0.10.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.9.0...barmark-v0.10.0
|
|
225
239
|
[0.9.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.8.0...barmark-v0.9.0
|
|
226
240
|
[0.8.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.7.0...barmark-v0.8.0
|
|
227
241
|
[0.7.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.6.0...barmark-v0.7.0
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
|
|
48
48
|
const chart = parseChart(text);
|
|
49
49
|
chart.title; // "Example Song"
|
|
50
|
-
chart.bars; // every bar in play order: slots, section, key, meter, tempo, feel (and swingPercent)
|
|
50
|
+
chart.bars; // every bar in play order: its number as written, slots, section, key, meter, tempo, feel (and swingPercent)
|
|
51
51
|
chart.sections; // each section as played, with its first and last bar
|
|
52
52
|
chart.diagnostics; // errors and warnings, each with a line number
|
|
53
53
|
|
package/dist/chart/barLine.d.ts
CHANGED
|
@@ -17,10 +17,12 @@ export declare function repeatTail(text: string, boundary: boolean): {
|
|
|
17
17
|
export declare function misplacedRepeat(token: string): string | null;
|
|
18
18
|
/**
|
|
19
19
|
* One bar line: cells between pipes, each cell's slots, the `|:` and `:|`
|
|
20
|
-
* marks and an `x N` tail. Any error drops the whole line (`bars` is null)
|
|
20
|
+
* marks and an `x N` tail. Any error drops the whole line (`bars` is null);
|
|
21
|
+
* `written` still says how many bars it writes.
|
|
21
22
|
*/
|
|
22
23
|
export declare function parseBarLine(text: string, line: number): {
|
|
23
24
|
bars: BarsLine | null;
|
|
25
|
+
written: number;
|
|
24
26
|
diagnostics: ChartDiagnostic[];
|
|
25
27
|
};
|
|
26
28
|
export {};
|
package/dist/chart/barLine.js
CHANGED
|
@@ -98,9 +98,16 @@ function tokens(text) {
|
|
|
98
98
|
out.push(current);
|
|
99
99
|
return out;
|
|
100
100
|
}
|
|
101
|
+
/** The bars a bar line writes, read from its pipes alone (fermatas not counted), so a line dropped for an error still counts. */
|
|
102
|
+
const barsWritten = (body) => body
|
|
103
|
+
.split("|")
|
|
104
|
+
.slice(1)
|
|
105
|
+
.map((p) => p.trim())
|
|
106
|
+
.filter((p) => p !== "" && !FERMATA.has(p)).length;
|
|
101
107
|
/**
|
|
102
108
|
* One bar line: cells between pipes, each cell's slots, the `|:` and `:|`
|
|
103
|
-
* marks and an `x N` tail. Any error drops the whole line (`bars` is null)
|
|
109
|
+
* marks and an `x N` tail. Any error drops the whole line (`bars` is null);
|
|
110
|
+
* `written` still says how many bars it writes.
|
|
104
111
|
*/
|
|
105
112
|
export function parseBarLine(text, line) {
|
|
106
113
|
const diagnostics = [];
|
|
@@ -136,13 +143,14 @@ export function parseBarLine(text, line) {
|
|
|
136
143
|
const closes = body.endsWith(":|");
|
|
137
144
|
if (closes)
|
|
138
145
|
body = `${body.slice(0, -2)}|`;
|
|
146
|
+
const written = barsWritten(body);
|
|
139
147
|
if (/\|\d/.test(body))
|
|
140
148
|
error("endings are not supported in v0.1", /\|\d+/.exec(body)?.[0] ?? "|");
|
|
141
149
|
if (body.includes(":|") || body.includes("|:"))
|
|
142
150
|
error("|: must open a bar line and :| must close one", body.includes(":|") ? ":|" : "|:");
|
|
143
151
|
// A misplaced mark makes the cells unreadable: report it once, not again as chords.
|
|
144
152
|
if (diagnostics.some((d) => d.severity === "error"))
|
|
145
|
-
return { bars: null, diagnostics };
|
|
153
|
+
return { bars: null, written, diagnostics };
|
|
146
154
|
const parts = body.split("|").slice(1);
|
|
147
155
|
if (parts.at(-1)?.trim() === "")
|
|
148
156
|
parts.pop();
|
|
@@ -237,6 +245,7 @@ export function parseBarLine(text, line) {
|
|
|
237
245
|
const failed = diagnostics.some((d) => d.severity === "error");
|
|
238
246
|
return {
|
|
239
247
|
bars: failed ? null : { kind: "bars", line, opens, closes, cells, repeat },
|
|
248
|
+
written,
|
|
240
249
|
diagnostics,
|
|
241
250
|
};
|
|
242
251
|
}
|
package/dist/chart/document.js
CHANGED
|
@@ -108,7 +108,7 @@ export function readDocument(text) {
|
|
|
108
108
|
if (t.startsWith("|")) {
|
|
109
109
|
const r = parseBarLine(t, line);
|
|
110
110
|
diagnostics.push(...r.diagnostics);
|
|
111
|
-
lines.push(r.bars ?? { kind: "invalid", line, text: t });
|
|
111
|
+
lines.push(r.bars ?? { kind: "invalid", line, text: t, written: r.written });
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
if (t.startsWith("# ")) {
|
package/dist/chart/expand.js
CHANGED
|
@@ -51,7 +51,10 @@ export function expand(lines) {
|
|
|
51
51
|
// % copies the bar written before it, one-bar meter included, so a section plays the same wherever it is replayed.
|
|
52
52
|
const resolved = new Map();
|
|
53
53
|
let previous = null;
|
|
54
|
+
let written = 0;
|
|
54
55
|
for (const l of sections.flatMap((s) => s.lines)) {
|
|
56
|
+
if (l.kind === "invalid")
|
|
57
|
+
written += l.written;
|
|
55
58
|
if (l.kind !== "bars")
|
|
56
59
|
continue;
|
|
57
60
|
const cells = [];
|
|
@@ -65,7 +68,8 @@ export function expand(lines) {
|
|
|
65
68
|
kind: "bar",
|
|
66
69
|
meter: previous?.meter ?? null,
|
|
67
70
|
slots: previous?.slots ?? [{ kind: "hold" }],
|
|
68
|
-
|
|
71
|
+
own: false,
|
|
72
|
+
written: ++written,
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
75
|
else {
|
|
@@ -73,7 +77,7 @@ export function expand(lines) {
|
|
|
73
77
|
const head = first?.kind === "group" ? first.members[0] : first;
|
|
74
78
|
if (!previous && head?.kind === "hold")
|
|
75
79
|
error(l.line, "/ has nothing before it to hold", "/");
|
|
76
|
-
cells.push({ kind: "bar", meter: c.meter, slots: c.slots,
|
|
80
|
+
cells.push({ kind: "bar", meter: c.meter, slots: c.slots, own: true, written: ++written });
|
|
77
81
|
previous = { meter: c.meter, slots: c.slots };
|
|
78
82
|
}
|
|
79
83
|
}
|
|
@@ -189,7 +193,7 @@ export function expand(lines) {
|
|
|
189
193
|
return stop(line);
|
|
190
194
|
count++;
|
|
191
195
|
const meter = p.meter ?? state.time;
|
|
192
|
-
if (p.
|
|
196
|
+
if (p.own && !checked.has(p)) {
|
|
193
197
|
checked.add(p);
|
|
194
198
|
const k = p.slots.length;
|
|
195
199
|
const b = beatsOf(meter);
|
|
@@ -206,6 +210,7 @@ export function expand(lines) {
|
|
|
206
210
|
kind: "bar",
|
|
207
211
|
bar: {
|
|
208
212
|
index: 0,
|
|
213
|
+
written: p.written,
|
|
209
214
|
line,
|
|
210
215
|
section: sectionName,
|
|
211
216
|
meter,
|
package/dist/chart/types.d.ts
CHANGED
|
@@ -93,15 +93,25 @@ export type Line = {
|
|
|
93
93
|
line: number;
|
|
94
94
|
text: string;
|
|
95
95
|
}
|
|
96
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* A bar line dropped for an error, kept as written so its section still
|
|
98
|
+
* counts as written out; `written` is how many bars its pipes write.
|
|
99
|
+
*/
|
|
97
100
|
| {
|
|
98
101
|
kind: "invalid";
|
|
99
102
|
line: number;
|
|
100
103
|
text: string;
|
|
104
|
+
written: number;
|
|
101
105
|
};
|
|
102
106
|
export type PlayedBar = {
|
|
103
107
|
/** 1-based measure number in play order; fermatas are not counted. */
|
|
104
108
|
index: number;
|
|
109
|
+
/**
|
|
110
|
+
* 1-based number of the bar as written, counting each written bar once
|
|
111
|
+
* (`%` included, fermatas not) in written order: a repeat or replay plays
|
|
112
|
+
* its bars under the numbers they were written with.
|
|
113
|
+
*/
|
|
114
|
+
written: number;
|
|
105
115
|
line: number;
|
|
106
116
|
/** Heading text of the section occurrence, as written. */
|
|
107
117
|
section: string | null;
|