Skip to main content

section-relationship

section-relationship(current: auto, it)(source)

Get the relationship of the current section a passed in outline entry. For past sections of another top-level section it returns -2, for past section of the current top-level section it returns -1. For the current section and children it returns 0, for future sections of the current top-level section it returns 1, and for future sections of another top-level section it returns 2.

Usage:

#{// displays all top levels and all levels of the current top-level,
// with future siblings and other top levels semi-transparent
// and the current entry bold
show outline.entry: it => {
let relationship = utils.section-relationship(it)
let current = utils.current-heading()
let alpha = if relationship == -2 or relationship > 0 {40%} else {100%}
let weight = if relationship == 0 and current.level == it.level { "bold" } else { "regular" }
if it.level > 1 and calc.abs(relationship) > 1 {
none
// text(fill:red, it) // this will show all non-displayed entries in red.
} else {
text(fill:utils.update-alpha(text.fill, alpha), weight: weight, it)
}
}
// if title is not none, it will create a new top-level heading which interferes with the computation
outline(title:none)
}
Parameters

current : content | none    default: auto

The current heading to compare with. Default is auto, which uses utils.current-heading().

it : content

The outline entry to compare with.

Returns: int