barmark 0.2.0 → 0.3.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 +16 -1
- package/dist/chart/document.js +32 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,20 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.3.0] - 2026-11-01
|
|
13
|
+
|
|
14
|
+
A chart in another format no longer reads as an empty one. A grammar
|
|
15
|
+
decision (two new warnings, §9); no chart's meaning changes. Implements the
|
|
16
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **A chart with no bar lines warns.** A chart with text but no bar line
|
|
21
|
+
at all warns once, at its first text line, instead of looking like an
|
|
22
|
+
empty file (issue #1). Grammar §9 and its decisions log.
|
|
23
|
+
- **Escaped pipes warn, with the fix.** A text line such as `D \| A \| G`,
|
|
24
|
+
as some editors save a bar line, warns and suggests `| D | A | G |`.
|
|
25
|
+
|
|
12
26
|
## [0.2.0] - 2026-10-31
|
|
13
27
|
|
|
14
28
|
Machine output for renderers and hosts (`form`, `parts`), the first
|
|
@@ -71,7 +85,8 @@ The first working release: the reference parser and printer for the
|
|
|
71
85
|
|
|
72
86
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
73
87
|
|
|
74
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
88
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.3.0...HEAD
|
|
89
|
+
[0.3.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.2.0...barmark-v0.3.0
|
|
75
90
|
[0.2.0]: https://github.com/kevinpeckham/barmark/compare/v0.1.0...barmark-v0.2.0
|
|
76
91
|
[0.1.0]: https://github.com/kevinpeckham/barmark/compare/v0.0.3...v0.1.0
|
|
77
92
|
[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
|
}
|