Skip to content

Commit

Permalink
Merge pull request #1191 from DDMAL/ghost-zone
Browse files Browse the repository at this point in the history
Fix collectFacsChildren() to get all children has @FACS recursively
  • Loading branch information
yinanazhou authored Feb 6, 2024
2 parents 2614ca0 + 23f05c2 commit 5600b28
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/utils/ConvertMei.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ export function convertToVerovio(sbBasedMei: string): string {
if (!nextSb) {
const lastElement = childrenArray.at(-1);
const facsChildren = collectFacsChildren(lastElement, []);
const zones = Array.from(surface.querySelectorAll('zone'));
for (const child of facsChildren) {
const zone = zones.find(z => z.getAttribute('xml:id') == child.getAttribute('facs').slice(1));
if (zone) {
Expand Down Expand Up @@ -577,11 +576,8 @@ export function removeColumnLabel(mei: string): string {
}

function collectFacsChildren(element: Element, array: Element[]): Element[] {
if (element.hasAttribute('facs')) array.push(element);
for (const child of element.children) {
if (child.hasAttribute('facs')) {
array.push(child);
}

// Recursively call the function for child's children
collectFacsChildren(child, array);
}
Expand Down

0 comments on commit 5600b28

Please sign in to comment.