`);
break;
case 'Part':
node.firstChild();
value = /^([a-zA-Z0-9]+)\..*$/.exec(text(input, node));
xml.push(`
`)
break;
case 'Column':
node.firstChild();
value = /^([a-zA-Z0-9]+)\..*$/.exec(text(input, node));
xml.push(`
`)
break;
case 'Foreign':
node.lastChild();
value = /^\|\~(.*)$/.exec(text(input, node));
xml.push(`
`);
node.parent();
break;
case 'Unclear':
const content = text(input, node);
let stripped = '';
for (let i = 0; i < content.length; i++) {
const codepoint = content.codePointAt(i);
if (codepoint && codepoint !== 0x0323) {
stripped += String.fromCodePoint(codepoint);
}
}
xml.push(`${stripped}`);
return false;
case 'Gap':
node.next(true);
xml.push(``);
return false;
case 'GapUnknown':
xml.push(``);
return false;
case 'Illegible':
value = /^\.([0-9?]+)(lin)?$/.exec(text(input, node));
if (value) {
if (value[2] === 'lin') {
if (value[1] === '?') {
xml.push(``);
} else {
xml.push(``);
}
} else if (value[1] === '?') {
xml.push(``);
} else {
xml.push(``);
}
}
return false;
case 'Erasure':
xml.push('');
break;
case 'LostLines':
value = /^lost\.([0-9?]+)lin$/.exec(text(input, node));
if (value) {
if (value[1] === '?') {
xml.push(``);
} else {
xml.push(``);
}
}
return false;
case 'AbbrevUnresolved':
xml.push('');
break;
case 'Abbrev':
if (stack.length > 0) {
node.lastChild();
value = text(input, node);
if (value.length > 0 && value.charAt(value.length - 1) === '?') {
xml.push(``);
} else {
xml.push(``);
}
node.parent();
} else {
xml.push('');
}
stack.push('expan');
break;
case 'Supplied':
node.lastChild();
if (node.name === 'CertLow') {
xml.push('');
} else {
xml.push('');
}
node.parent();
break;
case 'SuppliedLost':
node.lastChild();
if (node.name === 'CertLow') {
xml.push('');
} else {
xml.push('');
}
node.parent();
break;
case 'ForeignEnd':
case 'CertLow':
return false;
case 'QuestionMark':
if (stack.length < 2) {
xml.push('?');
}
return false;
case 'Inline':
break;
default:
xml.push(`<${name}>`);
break;
}
},
leave: (node) => {
switch (node.name) {
case 'Document':
if (needsWrap) {
xml.push(`\n${wrapper}>`);
}
break;
case 'AbbrevUnresolved':
xml.push('');
break;
case 'Abbrev':
if (stack.length > 1) {
const last = xml[xml.length - 1];
if (last.endsWith('?')) {
xml[xml.length - 1] = last.substring(0, last.length - 2);
}
xml.push('');
} else {
xml.push('');
}
stack.pop();
break;
case 'Div':
xml.push('');
break;
case 'Recto':
case 'Verso':
case 'Fragment':
case 'Part':
case 'Column':
xml.push('\n');
break;
case 'Supplied':
case 'SuppliedLost':
xml.push('');
break;
case 'Erasure':
xml.push('');
break;
case 'Foreign':
xml.push('');
break;
}
}
});
if (root.type.name === 'Inline') {
xml.push('');
}
return xml.join('');
}