barmark 0.2.0 → 0.4.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 +31 -1
- package/dist/chart/document.js +32 -0
- package/dist/chords/parse.js +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,34 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.4.0] - 2026-11-01
|
|
13
|
+
|
|
14
|
+
Charts written in Logic Pro's chord spelling read as they are. A grammar
|
|
15
|
+
decision (two new aliases, §3 and Appendix A.5); no chart that read
|
|
16
|
+
before changes meaning. 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
|
+
- **Logic Pro's parentheses are read.** Groups in a row are one list
|
|
22
|
+
(`C7(b9)(#11)` is `C7(b9,#11)`), and `(5)` on a bare root is the power
|
|
23
|
+
chord (`F#(5)(7)` is `F#5(7)`: F♯ C♯ E). Both print in the canonical
|
|
24
|
+
form. Grammar §3, Appendix A.5 and the decisions log.
|
|
25
|
+
|
|
26
|
+
## [0.3.0] - 2026-11-01
|
|
27
|
+
|
|
28
|
+
A chart in another format no longer reads as an empty one. A grammar
|
|
29
|
+
decision (two new warnings, §9); no chart's meaning changes. Implements the
|
|
30
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **A chart with no bar lines warns.** A chart with text but no bar line
|
|
35
|
+
at all warns once, at its first text line, instead of looking like an
|
|
36
|
+
empty file (issue #1). Grammar §9 and its decisions log.
|
|
37
|
+
- **Escaped pipes warn, with the fix.** A text line such as `D \| A \| G`,
|
|
38
|
+
as some editors save a bar line, warns and suggests `| D | A | G |`.
|
|
39
|
+
|
|
12
40
|
## [0.2.0] - 2026-10-31
|
|
13
41
|
|
|
14
42
|
Machine output for renderers and hosts (`form`, `parts`), the first
|
|
@@ -71,7 +99,9 @@ The first working release: the reference parser and printer for the
|
|
|
71
99
|
|
|
72
100
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
73
101
|
|
|
74
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
102
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.4.0...HEAD
|
|
103
|
+
[0.4.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.3.0...barmark-v0.4.0
|
|
104
|
+
[0.3.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.2.0...barmark-v0.3.0
|
|
75
105
|
[0.2.0]: https://github.com/kevinpeckham/barmark/compare/v0.1.0...barmark-v0.2.0
|
|
76
106
|
[0.1.0]: https://github.com/kevinpeckham/barmark/compare/v0.0.3...v0.1.0
|
|
77
107
|
[0.0.3]: https://github.com/kevinpeckham/barmark/compare/v0.0.2...v0.0.3
|
package/dist/chart/document.js
CHANGED
|
@@ -60,11 +60,40 @@ function oldFormat(text, line) {
|
|
|
60
60
|
const name = near?.[1] ? NEAR_DIRECTIVES[near[1].toLowerCase()] : undefined;
|
|
61
61
|
if (near && name)
|
|
62
62
|
return warn(`not a directive; did you mean ${name}:?`, `${name}: ${near[2]}`);
|
|
63
|
+
const unescaped = escapedBarLine(text);
|
|
64
|
+
if (unescaped)
|
|
65
|
+
return warn("escaped pipes; a bar line uses a plain |", unescaped);
|
|
63
66
|
const words = text.split(/\s+/);
|
|
64
67
|
if (words.length >= 2 && words.every((w) => parseChord(w).ok))
|
|
65
68
|
return warn("chords outside a bar line are text", `| ${words.join(" | ")} |`);
|
|
66
69
|
return null;
|
|
67
70
|
}
|
|
71
|
+
/** `D \| A \|` (an editor's escaping) as the bar line it would be, if it reads cleanly. */
|
|
72
|
+
function escapedBarLine(text) {
|
|
73
|
+
if (!text.includes("\\|"))
|
|
74
|
+
return null;
|
|
75
|
+
let fixed = text.replaceAll("\\|", "|").trim();
|
|
76
|
+
if (!fixed.startsWith("|"))
|
|
77
|
+
fixed = `| ${fixed}`;
|
|
78
|
+
if (!fixed.endsWith("|"))
|
|
79
|
+
fixed = `${fixed} |`;
|
|
80
|
+
const read = parseBarLine(fixed, 0);
|
|
81
|
+
return read.bars && read.diagnostics.length === 0 ? fixed : null;
|
|
82
|
+
}
|
|
83
|
+
/** A chart whose text holds no bar line at all says so, rather than looking empty. */
|
|
84
|
+
function noBarLines(lines) {
|
|
85
|
+
if (lines.some((l) => l.kind === "bars" || l.kind === "invalid"))
|
|
86
|
+
return null;
|
|
87
|
+
const first = lines.find((l) => l.kind === "text");
|
|
88
|
+
if (first?.kind !== "text")
|
|
89
|
+
return null;
|
|
90
|
+
return {
|
|
91
|
+
line: first.line,
|
|
92
|
+
severity: "warning",
|
|
93
|
+
message: "no bar lines in this chart; a bar line starts with |",
|
|
94
|
+
token: first.text,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
68
97
|
/** Classify every line of a chart: title, sections, directives, bar lines and text. */
|
|
69
98
|
export function readDocument(text) {
|
|
70
99
|
const lines = [];
|
|
@@ -112,5 +141,8 @@ export function readDocument(text) {
|
|
|
112
141
|
diagnostics.push(old);
|
|
113
142
|
lines.push({ kind: "text", line, text: t });
|
|
114
143
|
});
|
|
144
|
+
const empty = noBarLines(lines);
|
|
145
|
+
if (empty)
|
|
146
|
+
diagnostics.push(empty);
|
|
115
147
|
return { title, lines, diagnostics };
|
|
116
148
|
}
|
package/dist/chords/parse.js
CHANGED
|
@@ -61,6 +61,20 @@ function tokenize(symbol) {
|
|
|
61
61
|
return `cannot read "${rest}"`;
|
|
62
62
|
return { root, quality, extension: ext, sus, tones, bass };
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Logic Pro's spellings (Appendix A.5): groups in a row are one list
|
|
66
|
+
* (`(5)(7)` is `(5,7)`), and `5` in a bare root's group is the power chord
|
|
67
|
+
* (`F#(5,7)` is `F#5(7)`). After a quality or extension, `(5)` stays an error.
|
|
68
|
+
*/
|
|
69
|
+
function logicGroups(rest) {
|
|
70
|
+
const joined = rest.replace(/\)\(/g, ",");
|
|
71
|
+
const group = /^\(([^)]*)\)/.exec(joined);
|
|
72
|
+
const tones = group?.[1]?.split(",").map((t) => t.trim()) ?? [];
|
|
73
|
+
if (!group || !tones.includes("5"))
|
|
74
|
+
return joined;
|
|
75
|
+
const others = tones.filter((t) => t !== "5");
|
|
76
|
+
return `5${others.length ? `(${others.join(",")})` : ""}${joined.slice(group[0].length)}`;
|
|
77
|
+
}
|
|
64
78
|
/** Appendix A.5 and A.6: Unicode, rejections, then aliases into canonical vocabulary. */
|
|
65
79
|
function normalizeSymbol(symbol) {
|
|
66
80
|
const text = symbol.replace(/♯/g, "#").replace(/♭/g, "b");
|
|
@@ -71,6 +85,7 @@ function normalizeSymbol(symbol) {
|
|
|
71
85
|
let rest = text.slice(root.length);
|
|
72
86
|
for (const [pattern, replacement] of ALIASES)
|
|
73
87
|
rest = rest.replace(pattern, replacement);
|
|
88
|
+
rest = logicGroups(rest);
|
|
74
89
|
const added = [...rest.matchAll(/add(2|4|9|11)/g)].map((m) => m[1] ?? "");
|
|
75
90
|
if (added.length) {
|
|
76
91
|
rest = rest.replace(/add(2|4|9|11)/g, "");
|