@k-l-lambda/lilylet-markdown 0.1.19 → 0.1.20

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.
Files changed (2) hide show
  1. package/lib/index.js +11 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -67,11 +67,20 @@ async function renderLilylet(code, options) {
67
67
  if (!verovioToolkit) {
68
68
  return `<div class="${containerClass}" data-lilylet${sourceAttr}${meiAttr}></div>`;
69
69
  }
70
- // Calculate pageHeight based on measure count
70
+ // Calculate pageHeight based on measure count and staff count
71
71
  const measureCount = doc.measures?.length || 1;
72
+ // Calculate total staff count
73
+ let staffCount = 1;
74
+ if (doc.measures && doc.measures.length > 0) {
75
+ const firstMeasure = doc.measures[0];
76
+ staffCount = firstMeasure.parts.reduce((total, part) => {
77
+ const maxStaff = part.voices.reduce((max, voice) => Math.max(max, voice.staff || 1), 1);
78
+ return total + maxStaff;
79
+ }, 0) || 1;
80
+ }
72
81
  const basePageHeight = 2000;
73
82
  const measuresPerPage = 20;
74
- const pageHeight = Math.max(basePageHeight, Math.ceil(measureCount / measuresPerPage) * basePageHeight);
83
+ const pageHeight = Math.max(basePageHeight, Math.ceil(measureCount / measuresPerPage) * basePageHeight) * 2 * staffCount;
75
84
  // Set Verovio options with dynamic pageHeight
76
85
  if (verovioToolkit.setOptions) {
77
86
  verovioToolkit.setOptions({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-l-lambda/lilylet-markdown",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Markdown-it plugin for rendering Lilylet music notation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",