Footnotes: include links with <length> or <percentage> vertical-align

This commit is contained in:
John Factotum
2023-12-04 03:50:15 +08:00
parent 449842fd0a
commit 7d55731faf
+7 -3
View File
@@ -1,6 +1,11 @@
const getTypes = el => new Set(el?.getAttributeNS?.('http://www.idpf.org/2007/ops', 'type')?.split(' ')) const getTypes = el => new Set(el?.getAttributeNS?.('http://www.idpf.org/2007/ops', 'type')?.split(' '))
const getRoles = el => new Set(el?.getAttribute?.('role')?.split(' ')) const getRoles = el => new Set(el?.getAttribute?.('role')?.split(' '))
const isSuper = el => {
const { verticalAlign } = getComputedStyle(el)
return verticalAlign === 'super' || /^\d/.test(verticalAlign)
}
const refTypes = ['biblioref', 'glossref', 'noteref'] const refTypes = ['biblioref', 'glossref', 'noteref']
const refRoles = ['doc-biblioref', 'doc-glossref', 'doc-noteref'] const refRoles = ['doc-biblioref', 'doc-glossref', 'doc-noteref']
const isFootnoteReference = a => { const isFootnoteReference = a => {
@@ -9,9 +14,8 @@ const isFootnoteReference = a => {
return { return {
yes: refRoles.some(r => roles.has(r)) || refTypes.some(t => types.has(t)), yes: refRoles.some(r => roles.has(r)) || refTypes.some(t => types.has(t)),
maybe: () => !types.has('backlink') && !roles.has('doc-backlink') maybe: () => !types.has('backlink') && !roles.has('doc-backlink')
&& (getComputedStyle(a).verticalAlign === 'super' && (isSuper(a) || a.children.length === 1 && isSuper(a.children[0])
|| a.children.length === 1 && getComputedStyle(a.children[0]).verticalAlign === 'super') || isSuper(a.parentElement)),
|| getComputedStyle(a.parentElement).verticalAlign === 'super',
} }
} }