mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Footnotes: include links with <length> or <percentage> vertical-align
This commit is contained in:
+7
-3
@@ -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',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user