#Get Heading Text for Page Header
14 messages · Page 1 of 1 (latest)
You can get the body of the heading, though it won't contain the number. You could then in the same step also display the value of the heading counter at the respective heading location:
let headings = query(...).map(it => {
let num = if it.numbering != none {
numbering(it.numbering, ..counter(heading).at(it.location()))
sym.space
}
num + it.body
})
However, you probably don't need to reinvent the wheel and should check out the hydra package
Right, that’s what I’m doing, since i don’t need the number. However since it is a custom heading for the outline (it is actually just the title param overwritten) the body of the outline heading contains all the styling and it’s own body (including a line below the heading). For the other headings the body is simply (TEXT: „[…]“) - even though they are customized as well.
how are you passing the outline title parameter?
Don‘t have it open at this moment but iirc
via set outline and the passing in a content block to title
Does that content block include a heading itself, as in title: [= Outline] ? If yes, then it may be the case that the body of the outline heading is another heading element
I’ll check again tomorrow. But iirc it does not. It is only styled #text with some spacing and a #line.
oh I see, the line and the styles are in fact part of the body then
Hmm I see, so there is no way to „strip“ it then - to only extract the text?
Interestingly enough my normal level 1 headings also have this line but it does not appear in the body with the above query I posted..
I assume that you style your other headings via a show rule, with which the line is then not added to the body. Maybe it would be best to also use a show rule for the outline heading like
show outline: it => {
show heading: ...
it
}
Yes i think for headings I use
show headings.where(level: 1, numbering: „1.1“): ….
Interesting approach..what is the understanding behind that behavior, that I am missing? will definitely try that out and let you know. Thanks 🙂
Hmm I see, so there is no way to „strip“ it then - to only extract the text?
You can define a function that can convert content to string with something like this. though it's not always working perfectly. It may be fine in your case though
what is the understanding behind that behavior, that I am missing?
Show rules don't change the element itself (as in the body), but only how it should look given the already existing data. When you add the line or styles to the heading manually, they become an actual part of its body and not just of its look
Those sound like two good solutions. I think the former you mentioned might be „cleaner“, so will try that first. If not, a custom function should do the job fine, since this is one of the only cases, and I know what the repr of the outline title is.
Thanks, will keep you posted.