@barmark/render 0.12.0 → 0.13.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 CHANGED
@@ -6,6 +6,19 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.13.0] - 2026-11-04
10
+
11
+ Needs `barmark` 0.15.0.
12
+
13
+ ### Added
14
+
15
+ - **A chart's credits** (barmark's grammar 7.5), as a score sets them:
16
+ "Words and music by …" when the same people wrote both, otherwise
17
+ "Music by …" and "Words by …", then "Arranged by …", under the title
18
+ (`part="credits"`); several names read "A, B and C". The copyright
19
+ lines sit small at the chart's foot (`<footer part="copyright">`).
20
+ `ChartModel.credits` carries them and `creditsText` is exported.
21
+
9
22
  ## [0.12.0] - 2026-11-03
10
23
 
11
24
  Needs `barmark` 0.14.1.
@@ -317,7 +330,8 @@ that needs no script or as the `<barmark-chart>` web component. Requires
317
330
  zoom without sideways scrolling, the element renders and re-renders, and
318
331
  a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
319
332
 
320
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.12.0...HEAD
333
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.13.0...HEAD
334
+ [0.13.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.12.0...render-v0.13.0
321
335
  [0.12.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.11.0...render-v0.12.0
322
336
  [0.11.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.10.0...render-v0.11.0
323
337
  [0.10.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.9.1...render-v0.10.0
@@ -0,0 +1,3 @@
1
+ import type { Credits } from "barmark";
2
+ /** The header's credit lines, as a score sets them; the copyright goes to the foot. */
3
+ export declare function creditsText(credits: Credits): string[];
@@ -0,0 +1,23 @@
1
+ /** "A", "A and B", "A, B and C". */
2
+ function names(list) {
3
+ if (list.length < 2)
4
+ return list.join("");
5
+ return `${list.slice(0, -1).join(", ")} and ${list.at(-1)}`;
6
+ }
7
+ const same = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
8
+ /** The header's credit lines, as a score sets them; the copyright goes to the foot. */
9
+ export function creditsText(credits) {
10
+ const { composer, lyricist, arranger } = credits;
11
+ const lines = [];
12
+ if (composer.length > 0 && same(composer, lyricist))
13
+ lines.push(`Words and music by ${names(composer)}`);
14
+ else {
15
+ if (composer.length > 0)
16
+ lines.push(`Music by ${names(composer)}`);
17
+ if (lyricist.length > 0)
18
+ lines.push(`Words by ${names(lyricist)}`);
19
+ }
20
+ if (arranger.length > 0)
21
+ lines.push(`Arranged by ${names(arranger)}`);
22
+ return lines;
23
+ }
package/dist/html.js CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { printDirection, printPasses, } from "barmark";
7
7
  import { glyphs, NUMERALS, splitPitch, typesetChord, typesetNumeral, } from "./chord.js";
8
+ import { creditsText } from "./credits.js";
8
9
  import { escapeHtml } from "./escape.js";
9
10
  import { fontFaceCss } from "./font.js";
10
11
  import { isTacet as isTacetCell, layoutChart } from "./model.js";
@@ -52,7 +53,7 @@ function chartHtml(text, options) {
52
53
  // Every section's left column is as wide as the longest part label, so tutti rows line up with systems.
53
54
  const widest = Math.max(0, ...model.parts.map((p) => p.label?.length ?? 0));
54
55
  const gutter = parts ? ` data-parts style="--bm-label-chars:${widest}"` : "";
55
- return `<div class="bm-chart" data-theme="${themeOf(options)}"${gutter}${settings.barNumbers ? "" : ' data-bar-numbers="off"'}${options.wrap === false ? ' data-wrap="off"' : ""}>${headerHtml(model)}${model.blocks.map((b) => blockHtml(b, settings)).join("")}${options.diagnostics ? diagnosticsHtml(model) : ""}</div>`;
56
+ return `<div class="bm-chart" data-theme="${themeOf(options)}"${gutter}${settings.barNumbers ? "" : ' data-bar-numbers="off"'}${options.wrap === false ? ' data-wrap="off"' : ""}>${headerHtml(model)}${model.blocks.map((b) => blockHtml(b, settings)).join("")}${copyrightHtml(model)}${options.diagnostics ? diagnosticsHtml(model) : ""}</div>`;
56
57
  }
57
58
  function headerHtml(model) {
58
59
  const title = model.title
@@ -60,9 +61,19 @@ function headerHtml(model) {
60
61
  : "";
61
62
  const names = model.parts.length > 1 ? model.parts.map((p) => p.name).join(", ") : model.part?.name;
62
63
  const meta = [names ? escapeHtml(names) : "", metaText(model.header)].filter(Boolean).join(" · ");
63
- if (!title && !meta)
64
+ const credits = creditsText(model.credits)
65
+ .map((c) => `<p class="bm-credits" part="credits">${escapeHtml(c)}</p>`)
66
+ .join("");
67
+ if (!title && !credits && !meta)
64
68
  return "";
65
- return `<header class="bm-header">${title}${meta ? `<p class="bm-meta" part="meta">${meta}</p>` : ""}</header>`;
69
+ return `<header class="bm-header">${title}${credits}${meta ? `<p class="bm-meta" part="meta">${meta}</p>` : ""}</header>`;
70
+ }
71
+ /** The copyright lines, small, at the chart's foot. */
72
+ function copyrightHtml(model) {
73
+ const lines = model.credits.copyright;
74
+ if (lines.length === 0)
75
+ return "";
76
+ return `<footer class="bm-copyright" part="copyright">${lines.map((c) => `<p>${escapeHtml(c)}</p>`).join("")}</footer>`;
66
77
  }
67
78
  /** "rit. to ♩ = 90", "accel.", "a tempo". */
68
79
  function tempoChangeText(c) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type { Numerals } from "./chord.js";
2
+ export { creditsText } from "./credits.js";
2
3
  export { FONT_FAMILY, fontFaceCss } from "./font.js";
3
4
  export { type RenderOptions, renderChart, renderChartUnwrapped } from "./html.js";
4
5
  export { layoutChart } from "./model.js";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { creditsText } from "./credits.js";
1
2
  export { FONT_FAMILY, fontFaceCss } from "./font.js";
2
3
  export { renderChart, renderChartUnwrapped } from "./html.js";
3
4
  export { layoutChart } from "./model.js";
package/dist/model.js CHANGED
@@ -60,6 +60,7 @@ export function layoutChart(text, options = {}) {
60
60
  title: parse.title,
61
61
  part: parse.part,
62
62
  parts: parse.parts,
63
+ credits: parse.credits,
63
64
  header,
64
65
  blocks,
65
66
  diagnostics: parse.diagnostics,
@@ -88,22 +89,24 @@ function errorsByLine(parse) {
88
89
  }
89
90
  return errors;
90
91
  }
92
+ /** Lines that name the chart rather than play it: never part of the body. */
93
+ const NAMING = new Set(["title", "part", "credit"]);
91
94
  /** The title line, and the directives before any other content, form the header. */
92
95
  function splitHeader(lines) {
93
96
  const header = {};
94
97
  let i = 0;
95
98
  for (; i < lines.length; i++) {
96
99
  const l = lines[i];
97
- if (l?.kind === "title" || l?.kind === "part")
100
+ if (!l || NAMING.has(l.kind))
98
101
  continue;
99
- if (l?.kind !== "directive")
102
+ if (l.kind !== "directive")
100
103
  break;
101
104
  // A new feel replaces the old one whole, its amount included.
102
105
  if (l.set.feel)
103
106
  delete header.swingPercent;
104
107
  Object.assign(header, l.set);
105
108
  }
106
- return { header, body: lines.slice(i).filter((l) => l.kind !== "title" && l.kind !== "part") };
109
+ return { header, body: lines.slice(i).filter((l) => !NAMING.has(l.kind)) };
107
110
  }
108
111
  function groupLines(lines) {
109
112
  const groups = [];
package/dist/styles.js CHANGED
@@ -75,6 +75,9 @@ const css = `
75
75
  .bm-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
76
76
  .bm-header{margin-bottom:.8em}
77
77
  .bm-title{font-size:${em(SIZES.title)};font-weight:normal;margin:0 0 .15em}
78
+ .bm-credits{font-family:${LABEL};font-size:${em(SIZES.meta)};margin:0 0 .15em}
79
+ .bm-copyright{font-family:${LABEL};font-size:${em(SIZES.meta)};color:var(--bm-muted);margin-top:1.5em}
80
+ .bm-copyright p{margin:0}
78
81
  .bm-meta{font-family:${LABEL};font-size:${em(SIZES.meta)};color:var(--bm-muted);margin:0}
79
82
  .bm-directive{grid-column:1/-1;display:flex;align-items:baseline;gap:.4em;margin:.9em 0 .3em ${at(SIZES.directive, GUTTER)};font-family:${LABEL};font-size:${em(SIZES.directive)};color:var(--barmark-directive,var(--bm-muted))}
80
83
  .bm-directive::after{content:"";flex:1;align-self:center;margin-left:.4em;border-top:.06em solid var(--bm-rule);opacity:.6}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ChartDiagnostic, Direction, Directives, Key, Meter, Part, Repeat, Slot, Words } from "barmark";
1
+ import type { ChartDiagnostic, Credits, Direction, Directives, Key, Meter, Part, Repeat, Slot, Words } from "barmark";
2
2
  /** `part`: draw only the part with this label (barmark's grammar 7.4), as a single-part chart. */
3
3
  export type LayoutOptions = {
4
4
  rehearsalLetters?: boolean;
@@ -11,6 +11,8 @@ export type ChartModel = {
11
11
  part: Part | null;
12
12
  /** Every declared part, in score order (barmark's grammar 7.4). */
13
13
  parts: Part[];
14
+ /** The chart's credit lines (barmark's grammar 7.5). */
15
+ credits: Credits;
14
16
  /** Directives before the first heading, bar line or text line. */
15
17
  header: Directives;
16
18
  blocks: SectionBlock[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/render",
3
- "version": "0.12.0",
3
+ "version": "0.13.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,7 +47,7 @@
47
47
  "url": "https://github.com/kevinpeckham/barmark/issues"
48
48
  },
49
49
  "dependencies": {
50
- "barmark": "^0.14.1"
50
+ "barmark": "^0.15.0"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "rm -rf dist && tsc -p tsconfig.build.json",