Skip to content

Commit

Permalink
Footnotes: include links with <length> or <percentage> vertical-align
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Dec 3, 2023
1 parent 449842f commit 7d55731
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions footnotes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
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 isSuper = el => {
const { verticalAlign } = getComputedStyle(el)
return verticalAlign === 'super' || /^\d/.test(verticalAlign)
}

const refTypes = ['biblioref', 'glossref', 'noteref']
const refRoles = ['doc-biblioref', 'doc-glossref', 'doc-noteref']
const isFootnoteReference = a => {
Expand All @@ -9,9 +14,8 @@ const isFootnoteReference = a => {
return {
yes: refRoles.some(r => roles.has(r)) || refTypes.some(t => types.has(t)),
maybe: () => !types.has('backlink') && !roles.has('doc-backlink')
&& (getComputedStyle(a).verticalAlign === 'super'
|| a.children.length === 1 && getComputedStyle(a.children[0]).verticalAlign === 'super')
|| getComputedStyle(a.parentElement).verticalAlign === 'super',
&& (isSuper(a) || a.children.length === 1 && isSuper(a.children[0])
|| isSuper(a.parentElement)),
}
}

Expand Down

0 comments on commit 7d55731

Please sign in to comment.