I am trying to make a document that can export nicely to both HTML and PDF.
Notably, it has some configurations for things like page headers which I wish to exclude from the HTML export.
#set page(header: context {
if counter(page).get().first() > 1 [
#align(center, text[_My lovely essay_])
]
})
#set page(numbering: "— 1 —")
When I try to export to PDF, this fails due to page configuration not being allowed inside of containers.
error: page configuration is not allowed inside of containers
┌─ Essay.typ:7:1
│
7 │ #set page(header: context {
│ ╭──^
8 │ │ if counter(page).get().first() > 1 [
9 │ │ #align(center, text[_My lovely essay_])
10 │ │ ]
11 │ │ })
│ ╰──^
I have tried using the target() function to check for HTML export, but I haven’t managed to get it working.
I want to do something like:
#if target() == "paged" {
// PDF-specific options
} else if target() == "html" {
// HTML-specific options
}
How can I accomplish this?