diff --git a/lib/elements/fn.js b/lib/elements/fn.js index 54ebe7e..6c5c1a5 100644 --- a/lib/elements/fn.js +++ b/lib/elements/fn.js @@ -31,12 +31,22 @@ const getElementToInsertAfter = maybeBadAncestor => (maybeBadAncestor.nextElemen */ export default function (htmlParentNode, xmlnode) { if (xmlnode.closest('tex-math')) xmlnode.remove(); - const div = this.createNode('div', '', { role: 'doc-footnote', 'aria-label': `Footnote ${xmlnode.querySelector('label').textContent}` }); + const label = xmlnode.querySelector('label'); + const div = this.createNode('div', '', { role: 'doc-footnote', 'aria-label': `Footnote ${label.textContent}` }); // NOTE AmerMathSoc/texml-to-html#336 analyzed where fn occurs in publications; might need revisions // Essentially, we can assume fn occurs inside elements (that turn into) p, h1, and span (from formula markup) // Since a span ancestor can be inside p (e.g., from inline-formula) we check for the others first. const maybeBadAncestor = htmlParentNode.closest('p, h1') || htmlParentNode.closest('span'); maybeBadAncestor ? getElementToInsertAfter(maybeBadAncestor).insertAdjacentElement('afterend', div) : htmlParentNode.appendChild(div); mapAttributes(div, xmlnode); + // label + const span = this.createNode('span', '', { + 'data-ams-doc': 'label' + }); + div.appendChild(span); + const superscript = span.firstElementChild; + this.passThrough(superscript, label); + label.remove(); //NOTE: prevent duplicate processing later on + this.passThrough(div, xmlnode); }; diff --git a/lib/elements/label.js b/lib/elements/label.js index f9d7ce3..3ee907a 100644 --- a/lib/elements/label.js +++ b/lib/elements/label.js @@ -22,17 +22,6 @@ import getParentLevel from '../helpers/getParentLevel.js'; * @param {Element} xmlnode */ export default function (htmlParentNode, xmlnode) { - // simple cases - // CASE fn - if (xmlnode.parentNode.tagName === 'fn') { - const span = this.createNode('span', '', { - 'data-ams-doc': 'label' - }); - htmlParentNode.appendChild(span); - const superscript = span.firstElementChild; - this.passThrough(superscript, xmlnode); - return; - } // CASE label followed by a title -- we skip (and pull in the label later on when processing title) if (xmlnode.nextElementSibling?.tagName === 'title') return; // CASE empty label