barmark 0.6.0 → 0.8.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 +63 -1
- package/README.md +12 -2
- package/dist/chart/expand.js +15 -2
- package/dist/chart/index.d.ts +1 -1
- package/dist/chart/index.js +1 -1
- package/dist/chart/print.d.ts +5 -2
- package/dist/chart/print.js +6 -3
- package/dist/chords/parse.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,66 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.8.0] - 2026-11-02
|
|
13
|
+
|
|
14
|
+
`(add9)` and friends inside parentheses, clearer messages for an empty
|
|
15
|
+
section and a rejected tone, and grammar notes from Stem Shovel's issues.
|
|
16
|
+
Charts that read before read the same. Implements the
|
|
17
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **`(addN)` reads inside parentheses** (issue #62). `Am(add9)`,
|
|
22
|
+
`C(add2)`, `C(add4)` and `C(add11)` are aliases of `Am(9)`, `C(2)`,
|
|
23
|
+
`C(4)` and `C(11)`, alone or in a list (`C(b9,add11)` is `C(b9,11)`),
|
|
24
|
+
and print in the canonical form. `add13` and `add#11` stay errors.
|
|
25
|
+
Grammar Appendix A.5 and the decisions log.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **An empty section that matches nothing says how to fix it** (issue
|
|
30
|
+
#63). `## Progression` with no bars and no earlier section of that name
|
|
31
|
+
reported `no earlier section named "Progression" to replay`; it now
|
|
32
|
+
reports `"Progression" has no bars and no earlier section has that
|
|
33
|
+
name; write its bars under it, or remove the heading`. When the name is
|
|
34
|
+
written out later in the chart, the message says replays use only
|
|
35
|
+
earlier sections and gives that line. It is still an error: a section
|
|
36
|
+
with no bars replays (grammar §6), and there is no intentionally empty
|
|
37
|
+
section.
|
|
38
|
+
- **Grammar notes; no chart changes meaning.** §8 gains a note for
|
|
39
|
+
generators: write one slot per beat (the 2.1 beat, so 6/8 has two),
|
|
40
|
+
then canonicalize; a length that is not a whole number of beats needs
|
|
41
|
+
an eighth-note grid or a `_` group; leave out a section with no bars
|
|
42
|
+
(issue #64). §2.3: a tool that knows only the chord part writes `N.C.`
|
|
43
|
+
for its rests, not `--` (issue #65). §7.1: `feel:` names a kind of
|
|
44
|
+
groove, not an amount, so `swing 60%` stays an error, and the "custom
|
|
45
|
+
swing ratios" open question is closed (issue #66).
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **A rejected tone in parentheses is named as written.** `C(add9x)`
|
|
50
|
+
reported `"x" is not a tone a parenthesis can add`, and `Am(add9)`
|
|
51
|
+
reported `""`, because a bare `add9` was looked for inside the group
|
|
52
|
+
too; the message now quotes the tone as written (`"add9x"`).
|
|
53
|
+
|
|
54
|
+
## [0.7.0] - 2026-11-02
|
|
55
|
+
|
|
56
|
+
Print a chart you have already parsed, and conformance fixtures from real
|
|
57
|
+
charts. No grammar change: every chart reads as before. Implements the
|
|
58
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- **`printParsed(text, parsed)`**: the canonical text from a `parseChart`
|
|
63
|
+
result you already have, so a caller that needs both the parse and the
|
|
64
|
+
printed chart reads the text once.
|
|
65
|
+
- The stem-bench conformance fixtures (`tests/conformance/`): the four
|
|
66
|
+
public Badverbs charts exactly as stored in Stem Shovel, with expected
|
|
67
|
+
readings derived from the band's declared section starts and
|
|
68
|
+
stem-bench's independently-built verified bar lists (Study 16), plus
|
|
69
|
+
the grammar's trap rules as tests. A parser change that alters what a
|
|
70
|
+
real chart means now fails CI before it ships.
|
|
71
|
+
|
|
12
72
|
## [0.6.0] - 2026-11-01
|
|
13
73
|
|
|
14
74
|
Transposition, and scale degrees for numeral views. No grammar change:
|
|
@@ -142,7 +202,9 @@ The first working release: the reference parser and printer for the
|
|
|
142
202
|
|
|
143
203
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
144
204
|
|
|
145
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
205
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.8.0...HEAD
|
|
206
|
+
[0.8.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.7.0...barmark-v0.8.0
|
|
207
|
+
[0.7.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.6.0...barmark-v0.7.0
|
|
146
208
|
[0.6.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.5.0...barmark-v0.6.0
|
|
147
209
|
[0.5.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.4.0...barmark-v0.5.0
|
|
148
210
|
[0.4.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.3.0...barmark-v0.4.0
|
package/README.md
CHANGED
|
@@ -35,7 +35,15 @@ declarations included and no runtime dependencies.
|
|
|
35
35
|
## Use
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
degreeOf,
|
|
40
|
+
harteToBarmark,
|
|
41
|
+
parseChart,
|
|
42
|
+
parseChord,
|
|
43
|
+
printChart,
|
|
44
|
+
printParsed,
|
|
45
|
+
transposeChart,
|
|
46
|
+
} from "barmark";
|
|
39
47
|
|
|
40
48
|
const chart = parseChart(text);
|
|
41
49
|
chart.title; // "Example Song"
|
|
@@ -44,6 +52,7 @@ chart.sections; // each section as played, with its first and last bar
|
|
|
44
52
|
chart.diagnostics; // errors and warnings, each with a line number
|
|
45
53
|
|
|
46
54
|
printChart(text); // the chart in canonical form (same meaning, standard spelling)
|
|
55
|
+
printParsed(text, chart); // the same, from a parse you already have
|
|
47
56
|
|
|
48
57
|
transposeChart("key: D\n| D | A | Bm | G |", { to: "Eb" }).text; // "key: Eb\n| Eb | Bb | Cm | Ab |\n"
|
|
49
58
|
transposeChart(text, { semitones: -2 }); // { text, diagnostics }
|
|
@@ -60,7 +69,8 @@ harteToBarmark("A:sus4(b7,9)"); // "A9sus4"
|
|
|
60
69
|
- **`parseChart`** never throws. A line with an error is left out of the
|
|
61
70
|
play order and reported, and the rest of the chart still reads.
|
|
62
71
|
- **`printChart`** changes spelling and layout only: lines with errors and
|
|
63
|
-
lyrics print exactly as written.
|
|
72
|
+
lyrics print exactly as written. **`printParsed`** does the same from an
|
|
73
|
+
existing `parseChart` result, for a caller that needs both.
|
|
64
74
|
- **`transposeChart`** moves every chord root, slash bass, note set and
|
|
65
75
|
`key:` line, and never the words. Chords are spelled by their interval
|
|
66
76
|
from the chart's first key, so each keeps its place in the key: C in D
|
package/dist/chart/expand.js
CHANGED
|
@@ -4,6 +4,19 @@ export const MAX_EXPANDED_BARS = 10_000;
|
|
|
4
4
|
/** Repeats of bodies that play no bars (fermatas only) are bounded too. */
|
|
5
5
|
const MAX_WORK = MAX_EXPANDED_BARS * 10;
|
|
6
6
|
const normalize = (name) => name.toLowerCase().replace(/\s+/g, " ").trim();
|
|
7
|
+
const isWritten = (s) => s.lines.some((l) => l.kind === "bars" || l.kind === "invalid");
|
|
8
|
+
/** Grammar §6: an empty section that matches nothing, and how to fix it. */
|
|
9
|
+
function unmatchedReplay(heading, sections) {
|
|
10
|
+
const name = normalize(heading.name);
|
|
11
|
+
const later = sections.find((s) => s.heading &&
|
|
12
|
+
s.heading.line > heading.line &&
|
|
13
|
+
normalize(s.heading.name) === name &&
|
|
14
|
+
isWritten(s))?.heading;
|
|
15
|
+
const fix = later
|
|
16
|
+
? `replays use only earlier sections (it is written at line ${later.line})`
|
|
17
|
+
: "write its bars under it, or remove the heading";
|
|
18
|
+
return `"${heading.name}" has no bars and no earlier section has that name; ${fix}`;
|
|
19
|
+
}
|
|
7
20
|
/** Every played bar in order, with an open repeat's pass included once. */
|
|
8
21
|
export function flattenBars(events) {
|
|
9
22
|
return events.flatMap((e) => e.kind === "bar" ? [e.bar] : e.kind === "open" ? flattenBars(e.events) : []);
|
|
@@ -258,7 +271,7 @@ export function expand(lines) {
|
|
|
258
271
|
}
|
|
259
272
|
sectionName = h.name;
|
|
260
273
|
const out = [];
|
|
261
|
-
const isDefinition = s
|
|
274
|
+
const isDefinition = isWritten(s);
|
|
262
275
|
let replayOf = null;
|
|
263
276
|
if (isDefinition) {
|
|
264
277
|
definitions.set(normalize(h.name), s);
|
|
@@ -272,7 +285,7 @@ export function expand(lines) {
|
|
|
272
285
|
continue;
|
|
273
286
|
const source = definitions.get(normalize(h.name));
|
|
274
287
|
if (!source?.heading) {
|
|
275
|
-
error(h.line,
|
|
288
|
+
error(h.line, unmatchedReplay(h, sections), h.name);
|
|
276
289
|
continue;
|
|
277
290
|
}
|
|
278
291
|
replayOf = source.heading.line;
|
package/dist/chart/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { beatsOf, DIRECTIVE_NAMES, parseDirectiveLine, parseMeter } from "./dire
|
|
|
4
4
|
export { readDocument } from "./document.js";
|
|
5
5
|
export { expand, flattenBars, MAX_EXPANDED_BARS } from "./expand.js";
|
|
6
6
|
export { parseChart } from "./parse.js";
|
|
7
|
-
export { printCell, printChart, printLine, printSlot, reduceSlots } from "./print.js";
|
|
7
|
+
export { printCell, printChart, printLine, printParsed, printSlot, reduceSlots } from "./print.js";
|
|
8
8
|
export { type TransposeBy, transposeChart } from "./transpose.js";
|
|
9
9
|
export type * from "./types.js";
|
package/dist/chart/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { beatsOf, DIRECTIVE_NAMES, parseDirectiveLine, parseMeter } from "./dire
|
|
|
4
4
|
export { readDocument } from "./document.js";
|
|
5
5
|
export { expand, flattenBars, MAX_EXPANDED_BARS } from "./expand.js";
|
|
6
6
|
export { parseChart } from "./parse.js";
|
|
7
|
-
export { printCell, printChart, printLine, printSlot, reduceSlots } from "./print.js";
|
|
7
|
+
export { printCell, printChart, printLine, printParsed, printSlot, reduceSlots } from "./print.js";
|
|
8
8
|
export { transposeChart } from "./transpose.js";
|
package/dist/chart/print.d.ts
CHANGED
|
@@ -23,5 +23,8 @@ export declare function printLine(l: Line, beats?: (number | undefined)[]): stri
|
|
|
23
23
|
* fences stay. Never throws.
|
|
24
24
|
*/
|
|
25
25
|
export declare function printChart(text: string): string;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* `printChart` over a parse you already have (`parseChart(text)`), so the
|
|
28
|
+
* text isn't read twice. `edit`, if given, changes each line before it prints.
|
|
29
|
+
*/
|
|
30
|
+
export declare function printParsed(text: string, parsed: ChartParse, edit?: (l: Line) => Line): string;
|
package/dist/chart/print.js
CHANGED
|
@@ -106,10 +106,13 @@ export function printLine(l, beats = []) {
|
|
|
106
106
|
* fences stay. Never throws.
|
|
107
107
|
*/
|
|
108
108
|
export function printChart(text) {
|
|
109
|
-
return printParsed(text, parseChart(text)
|
|
109
|
+
return printParsed(text, parseChart(text));
|
|
110
110
|
}
|
|
111
|
-
/**
|
|
112
|
-
|
|
111
|
+
/**
|
|
112
|
+
* `printChart` over a parse you already have (`parseChart(text)`), so the
|
|
113
|
+
* text isn't read twice. `edit`, if given, changes each line before it prints.
|
|
114
|
+
*/
|
|
115
|
+
export function printParsed(text, parsed, edit = (l) => l) {
|
|
113
116
|
const byLine = new Map(parsed.lines.map((l) => [l.line, l]));
|
|
114
117
|
const errored = new Set(parsed.diagnostics.filter((d) => d.severity === "error").map((d) => d.line));
|
|
115
118
|
// Each cell's beat count on its first play, which is when its slot count is checked.
|
package/dist/chords/parse.js
CHANGED
|
@@ -86,9 +86,13 @@ function normalizeSymbol(symbol) {
|
|
|
86
86
|
for (const [pattern, replacement] of ALIASES)
|
|
87
87
|
rest = rest.replace(pattern, replacement);
|
|
88
88
|
rest = logicGroups(rest);
|
|
89
|
-
|
|
89
|
+
// `(add9)` is `(9)`: inside a group, `add` before a tone it may add is dropped.
|
|
90
|
+
rest = rest.replace(/(?<=[(,]\s*)add(2|4|9|11)(?=\s*[,)])/g, "$1");
|
|
91
|
+
// A bare `add9` outside any group; what is left inside one is the tokenizer's to name.
|
|
92
|
+
const bare = /add(2|4|9|11)(?![^(]*\))/g;
|
|
93
|
+
const added = [...rest.matchAll(bare)].map((m) => m[1] ?? "");
|
|
90
94
|
if (added.length) {
|
|
91
|
-
rest = rest.replace(
|
|
95
|
+
rest = rest.replace(bare, "");
|
|
92
96
|
const close = rest.indexOf(")");
|
|
93
97
|
if (close >= 0)
|
|
94
98
|
rest = `${rest.slice(0, close)},${added.join(",")}${rest.slice(close)}`;
|