From 59847c7e2f564f23122dd0ec0109c66ffdc680b6 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Mon, 18 Mar 2024 11:36:46 -0400 Subject: [PATCH] Break loop for empty neume section --- src/utils/ConvertMei.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/ConvertMei.ts b/src/utils/ConvertMei.ts index 621a19cd..c96099d0 100644 --- a/src/utils/ConvertMei.ts +++ b/src/utils/ConvertMei.ts @@ -52,7 +52,8 @@ export function convertToNeon(staffBasedMei: string): string { const mei = meiDoc.documentElement; let nCol = 0; - for (const section of mei.querySelectorAll('section:not([type="neon-neume-line"])')) { + const sections = Array.from(mei.querySelectorAll('section:not([type="neon-neume-line"])')); + for (const section of sections) { // Remove direct children pb elements within section const pbs = section.querySelectorAll('pb'); pbs.forEach(pb => pb.remove()); @@ -78,6 +79,10 @@ export function convertToNeon(staffBasedMei: string): string { for (const neonNeumeLineSection of neonNeumeLineSections) { nStaff += 1; const staff = neonNeumeLineSection.querySelector('staff'); + if (!staff) { + neonNeumeLineSection.remove(); + continue; + } const layer = staff.querySelector('layer'); // if staff has a new type value,