@barmark/render 0.22.2 → 0.23.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 +33 -1
- package/README.md +11 -10
- package/dist/element.js +2 -2
- package/dist/html.d.ts +3 -2
- package/dist/html.js +2 -2
- package/dist/model.js +14 -4
- package/dist/types.d.ts +7 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,36 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.23.0] - 2026-11-30
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Bar numbers count the bars on the page, a replayed section included**
|
|
14
|
+
(Kevin, 2026-11-30). A heading with no bars under it replays its
|
|
15
|
+
section, and the grid draws that section's rows again; they used to
|
|
16
|
+
show the numbers the section was written with, so the numbers down the
|
|
17
|
+
page repeated (1, 2, 6, 10, 12, 16, 20, 10, 12, 12, 24). Now a replayed
|
|
18
|
+
section counts as written again where its heading is: its rows go on
|
|
19
|
+
from the count, and every section after it counts them too (1, 2, 6,
|
|
20
|
+
10, 12, 16, 20, 24, 26, 30, 34). A screen reader hears the same numbers,
|
|
21
|
+
with the numbers hidden too (`barNumbers: false`), where bars are still
|
|
22
|
+
spoken by number.
|
|
23
|
+
A repeat still counts its bars once, a chart with no replay that plays
|
|
24
|
+
is numbered as before, and played numbers (`barNumbers: "played"`) do
|
|
25
|
+
not change. The numbers come from the parser's `pageShift`.
|
|
26
|
+
- **Requires `barmark` 0.27.0**, for `pageShift`: the range is now
|
|
27
|
+
`>=0.27.0 <1.0.0`.
|
|
28
|
+
|
|
29
|
+
## [0.22.3] - 2026-11-30
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **Works with any `@barmark/fretboard` 0.x from 0.1.0.** The dependency
|
|
34
|
+
was a caret range, which in 0.x stops at the next minor, so every
|
|
35
|
+
`fretboard` minor needed a release of this package before the two
|
|
36
|
+
could be installed together as one copy. It is now `>=0.1.0 <1.0.0`.
|
|
37
|
+
Nothing else changes.
|
|
38
|
+
|
|
9
39
|
## [0.22.2] - 2026-11-30
|
|
10
40
|
|
|
11
41
|
### Changed
|
|
@@ -674,7 +704,9 @@ that needs no script or as the `<barmark-chart>` web component. Requires
|
|
|
674
704
|
zoom without sideways scrolling, the element renders and re-renders, and
|
|
675
705
|
a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
|
|
676
706
|
|
|
677
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.
|
|
707
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.23.0...HEAD
|
|
708
|
+
[0.23.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.3...render-v0.23.0
|
|
709
|
+
[0.22.3]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.2...render-v0.22.3
|
|
678
710
|
[0.22.2]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.1...render-v0.22.2
|
|
679
711
|
[0.22.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.22.0...render-v0.22.1
|
|
680
712
|
[0.22.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.21.1...render-v0.22.0
|
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ the element loads, with `<style data-barmark-font>` holding
|
|
|
81
81
|
| `renderChart` option | Element attribute (property) | Default | |
|
|
82
82
|
|---|---|---|---|
|
|
83
83
|
| `theme` | `theme` (`theme`) | `"auto"` | `"auto"` follows the system; `"light"` or `"dark"` force one |
|
|
84
|
-
| `barNumbers` | `bar-numbers="off"` or `"played"` (`barNumbers`) | `true` | bar numbers at the start of each row: `true`
|
|
84
|
+
| `barNumbers` | `bar-numbers="off"` or `"played"` (`barNumbers`) | `true` | bar numbers at the start of each row: `true` the bars counted down the page, a replayed section counted as written again; `false` or `"off"` none; `"played"` numbers in play order (below). Any other attribute value is the default |
|
|
85
85
|
| `rehearsalLetters` | `rehearsal-letters` (`rehearsalLetters`) | `false` | boxed A, B, C… on each section as played; none when the chart writes a rehearsal mark of its own (below) |
|
|
86
86
|
| `numerals` | `numerals` (`numerals`) | none | `"nashville"` (6m⁷) or `"roman"` (vi⁷): each chord as its degree in its bar's key |
|
|
87
87
|
| `wrap` | `wrap="off"` (`wrap`) | `true` | wrap a section's rows when it is wider than the chart's box; off, rows keep their columns and the chart overflows, for its page to scroll |
|
|
@@ -126,7 +126,7 @@ played more than once where it is drawn (inside `|: :|`, under `x N`, or
|
|
|
126
126
|
where a `D.S.` or `D.C.` returns) shows its first bar's number on each pass,
|
|
127
127
|
`1 · 5`, up to three; four or more show the first and the last, `9 … 37`.
|
|
128
128
|
A row no pass plays shows none. A pickup's first pass is 0 and never
|
|
129
|
-
shown, as
|
|
129
|
+
shown, as in the default; a later pass of its row (inside `|: :|`,
|
|
130
130
|
or where a `D.C.` returns) shows its number. An open repeat (`x ...`) is
|
|
131
131
|
counted once, since its passes are unknown: every number after it is
|
|
132
132
|
approximate and shows as `~11`. A screen reader hears each bar's own
|
|
@@ -134,11 +134,11 @@ numbers: "bar 1 and bar 5", "bars 1, 5 and 9", "bars 9 to 37, 8 times",
|
|
|
134
134
|
"about bar 11", "about bars 12, 14 and 16". The gutter widens to the
|
|
135
135
|
longest numbers on one line, and a section wraps sooner to make room for
|
|
136
136
|
it. In a chart without part labels, headings, text lines and directives
|
|
137
|
-
start where the bars do, as
|
|
138
|
-
keep their place over the label column, as in
|
|
137
|
+
start where the bars do, as in the default; with part labels they
|
|
138
|
+
keep their place over the label column, as in the default. Played markup
|
|
139
139
|
carries the few rules that do this, so a page that includes `stylesheet`
|
|
140
|
-
needs nothing more.
|
|
141
|
-
what a printed chart and a band use; the model gives played numbers as
|
|
140
|
+
needs nothing more. The bars counted down the page stay the default
|
|
141
|
+
because they are what a printed chart and a band use; the model gives played numbers as
|
|
142
142
|
`playedNumbers` on each row and bar (`{ bar, approximate }`, a pass each)
|
|
143
143
|
only in this mode.
|
|
144
144
|
|
|
@@ -298,11 +298,12 @@ Chords appear in their canonical form whatever the author typed (`Cø`
|
|
|
298
298
|
shows as Cm⁷(♭5)). `%` is drawn as the bar it copies (as the `%` sign
|
|
299
299
|
where no pass plays it); a replayed section
|
|
300
300
|
is drawn in full, and its own lyrics replace the written section's. Bar
|
|
301
|
-
numbers count the bars
|
|
302
|
-
repeat, an ending
|
|
303
|
-
|
|
301
|
+
numbers count the bars down the page, each once, as a band counts them: a
|
|
302
|
+
repeat, an ending or a jump doesn't move them, and a replayed section
|
|
303
|
+
counts as written again where its heading is, so its rows go on from the
|
|
304
|
+
count and the numbers after it never repeat (the parser's `pageShift`). A pickup is bar 0: its
|
|
304
305
|
row shows no number in the gutter (`barNumber` is `0` in the model) and
|
|
305
|
-
is spoken as "pickup", and the bars after it are 1, 2, and so on. A line with an error shows as written, underlined,
|
|
306
|
+
is spoken as "pickup", and the bars after it are 1, 2, and so on; drawn again by a replay, the pickup's row is a bar like any other, numbered and spoken with its place in the count. A line with an error shows as written, underlined,
|
|
306
307
|
with its message, unless its only errors are slots that can't be read
|
|
307
308
|
(`CM7`): that line draws as usual, each such slot as written in the
|
|
308
309
|
error colour with its message as a tooltip and in the bar's spoken name. `layoutChart(text)` returns all of this as data, if
|
package/dist/element.js
CHANGED
|
@@ -8,7 +8,7 @@ import { NUMERALS } from "./chord.js";
|
|
|
8
8
|
import { FONT_FAMILY, fontFaceCss } from "./font.js";
|
|
9
9
|
import { loadErrorContent, shadowContent, THEMES, } from "./html.js";
|
|
10
10
|
const HANDS = ["left", "right"];
|
|
11
|
-
/** `bar-numbers`: "off" hides them, "played" counts in play order, anything else (none included)
|
|
11
|
+
/** `bar-numbers`: "off" hides them, "played" counts in play order, anything else (none included) counts down the page. */
|
|
12
12
|
const barNumbersOf = (value) => value === "played" ? "played" : value !== "off";
|
|
13
13
|
export function optionsFromAttributes(el) {
|
|
14
14
|
const theme = el.getAttribute("theme");
|
|
@@ -121,7 +121,7 @@ function defineElement() {
|
|
|
121
121
|
set theme(v) {
|
|
122
122
|
this.setAttribute("theme", v);
|
|
123
123
|
}
|
|
124
|
-
/** true for
|
|
124
|
+
/** true for the bars counted down the page, "played" for numbers in play order, false for none (set `false`, `"off"` or any falsy value). */
|
|
125
125
|
get barNumbers() {
|
|
126
126
|
return barNumbersOf(this.getAttribute("bar-numbers"));
|
|
127
127
|
}
|
package/dist/html.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { type Numerals } from "./chord.js";
|
|
|
2
2
|
export type RenderOptions = {
|
|
3
3
|
theme?: "auto" | "light" | "dark";
|
|
4
4
|
/**
|
|
5
|
-
* Bar numbers at the start of each row: `true` (the default),
|
|
6
|
-
*
|
|
5
|
+
* Bar numbers at the start of each row: `true` (the default), the bars
|
|
6
|
+
* counted down the page, each written bar once and a replayed section
|
|
7
|
+
* counted as written again; `false` or `"off"`, none; `"played"`, each row's place in play
|
|
7
8
|
* order, a number a pass (`1 · 5`), `~` after a vamp. Any other value is
|
|
8
9
|
* written, but for `0` or `""`, which hide them as `false` does; `null`,
|
|
9
10
|
* like none, is the default.
|
package/dist/html.js
CHANGED
|
@@ -361,8 +361,8 @@ function gutterHtml(row, settings, part) {
|
|
|
361
361
|
if (!settings.gutter)
|
|
362
362
|
return "";
|
|
363
363
|
const lead = settings.barNumbers && (!part || part.first);
|
|
364
|
-
const
|
|
365
|
-
const number = lead ? (settings.played ? playedText(row) :
|
|
364
|
+
const page = row.barNumber !== 0 ? (row.barNumber ?? "") : "";
|
|
365
|
+
const number = lead ? (settings.played ? playedText(row) : page) : "";
|
|
366
366
|
const label = part
|
|
367
367
|
? `<span class="bm-part-label" part="part-label">${escapeHtml(part.label)}</span>`
|
|
368
368
|
: "";
|
package/dist/model.js
CHANGED
|
@@ -114,6 +114,7 @@ export function layoutChart(text, options = {}) {
|
|
|
114
114
|
changed: false,
|
|
115
115
|
melodies: new Map(),
|
|
116
116
|
numbering: options.barNumbers === "played" ? numberingOf(parse) : null,
|
|
117
|
+
pageShift: 0,
|
|
117
118
|
};
|
|
118
119
|
const blocks = groups.map((g) => layoutGroup(g, ctx));
|
|
119
120
|
// A chart that writes its own rehearsal marks keeps them alone: letters beside them would mark each place twice.
|
|
@@ -216,12 +217,15 @@ function groupLines(lines) {
|
|
|
216
217
|
groups.push(current);
|
|
217
218
|
return groups;
|
|
218
219
|
}
|
|
220
|
+
/** What a section's rows add to their written numbers: the parser counts the bars on the page, a replay's going on from the count (barmark's grammar A.7). */
|
|
221
|
+
const pageShiftOf = (h) => h?.pageShift ?? 0;
|
|
219
222
|
function layoutGroup(group, ctx) {
|
|
220
223
|
const h = group.heading;
|
|
221
224
|
const occurrence = h ? ctx.parse.sections.find((s) => s.line === h.line) : undefined;
|
|
222
225
|
// A heading with an error is drawn as written, like any line with an error.
|
|
223
226
|
const broken = h !== null && ctx.errors.has(h.line);
|
|
224
227
|
const written = occurrence?.replayOf != null ? ctx.written.get(occurrence.replayOf) : undefined;
|
|
228
|
+
ctx.pageShift = pageShiftOf(h);
|
|
225
229
|
const items = [
|
|
226
230
|
...(broken ? [errorItem(h.line, ctx)] : []),
|
|
227
231
|
...(written && occurrence
|
|
@@ -248,7 +252,7 @@ const unplayed = (h) => ({
|
|
|
248
252
|
form: 0,
|
|
249
253
|
});
|
|
250
254
|
/**
|
|
251
|
-
* A replay draws its written section
|
|
255
|
+
* A replay draws its written section, its bars numbered on down the page. Its own
|
|
252
256
|
* text lines replace the written section's in order (extra ones follow the
|
|
253
257
|
* last row); its other lines follow. `->` marks the bar the parser cut.
|
|
254
258
|
*/
|
|
@@ -630,14 +634,20 @@ function layoutRow(l, occurrence, previous, ctx) {
|
|
|
630
634
|
const row = {
|
|
631
635
|
kind: "row",
|
|
632
636
|
line: l.line,
|
|
633
|
-
// Numbered
|
|
634
|
-
|
|
637
|
+
// Numbered down the page (issue #92, barmark's grammar A.7): each written bar once, repeats,
|
|
638
|
+
// endings and jumps not moving it, a replayed section counted as written again.
|
|
639
|
+
barNumber: pageNumber(l.line, ctx),
|
|
635
640
|
...rowMarks(l),
|
|
636
641
|
cells: withUnread(cells, l, ctx),
|
|
637
642
|
...singing(l, cells, occurrence, ctx),
|
|
638
643
|
};
|
|
639
644
|
return withPlayedNumbers(row, occurrence, ctx);
|
|
640
645
|
}
|
|
646
|
+
/** A row's number on the page: its line's written first, shifted by its section's place; none for a row no pass plays. */
|
|
647
|
+
function pageNumber(line, ctx) {
|
|
648
|
+
const start = ctx.starts.get(line);
|
|
649
|
+
return start === undefined ? null : start + ctx.pageShift;
|
|
650
|
+
}
|
|
641
651
|
/**
|
|
642
652
|
* The bars a line plays in its drawn occurrence: the section occurrence the
|
|
643
653
|
* heading draws and any a jump makes of it (the parser gives a D.S. or D.C.
|
|
@@ -669,7 +679,7 @@ function withPlayedNumbers(row, occurrence, ctx) {
|
|
|
669
679
|
byWritten.set(b.written, [playedNumber(b, numbering)]);
|
|
670
680
|
}
|
|
671
681
|
// Written numbers run on along a line, a bar a cell, whichever bars a pass leaves out.
|
|
672
|
-
let written = row.
|
|
682
|
+
let written = ctx.starts.get(row.line) ?? null;
|
|
673
683
|
const cells = row.cells.map((c) => {
|
|
674
684
|
if (c.kind !== "slots")
|
|
675
685
|
return c;
|
package/dist/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type LayoutOptions = {
|
|
|
18
18
|
melody?: boolean;
|
|
19
19
|
/** Give the model a diagram entry for each chord, as a guitar plays it; off when absent. */
|
|
20
20
|
chordDiagrams?: "guitar";
|
|
21
|
-
/** `"played"`: give each row and bar its played numbers (`playedNumbers`);
|
|
21
|
+
/** `"played"`: give each row and bar its played numbers (`playedNumbers`); `barNumber` stays as it is. */
|
|
22
22
|
barNumbers?: boolean | "played";
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -90,7 +90,12 @@ export type RowItem = Extract<BlockItem, {
|
|
|
90
90
|
export type BlockItem = {
|
|
91
91
|
kind: "row";
|
|
92
92
|
line: number;
|
|
93
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* The number of the row's first bar on the page: its written number
|
|
95
|
+
* (`PlayedBar.written`), counted on past each replay drawn above it, so
|
|
96
|
+
* a replay's rows go on from the count (the heading's `pageShift`,
|
|
97
|
+
* barmark's grammar A.7). Null for a row with no bar, or none a pass plays.
|
|
98
|
+
*/
|
|
94
99
|
barNumber: number | null;
|
|
95
100
|
/** With `barNumbers: "played"`: the played number of the row's first bar on each pass of this drawn occurrence, in order; empty when no pass plays it. */
|
|
96
101
|
playedNumbers?: PlayedNumber[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Render barmark chord charts as a clean, accessible bar grid: HTML with Declarative Shadow DOM, or the <barmark-chart> web component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"url": "https://github.com/kevinpeckham/barmark/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@barmark/fretboard": "
|
|
51
|
-
"barmark": ">=0.
|
|
50
|
+
"@barmark/fretboard": ">=0.1.0 <1.0.0",
|
|
51
|
+
"barmark": ">=0.27.0 <1.0.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|