It has probably been asked before, but I couldn’t find it. Is there a way to increase the maximum number of iterations from the default of 5 when using introspection ? 5 is a sensible limit on simple documents, but it can be limiting on more complex documents, especially with the new bundle feature.
My usecase :
I use the bundle feature to build a website, and also offer some pages as PDF. To avoid having to declare every pages in the bundle, I use a variant of the solution proposed in 8249
// template.typ
// Insert a link to target and requests the compilation of the document
#let inclink( target, src: auto, file-target: auto,
path-cb: none, body, ..attrs
) = {
src = if (src == auto) {
if (target.split("/").last() == "") {
target + "index.typ"
} else if (target.endswith(regex("\.(html|pdf)"))) {
target.trim(regex("\.(html|pdf)")) + ".typ"
} else {
target
}
} else { src }
file-target = if (file-target == auto) {
if (target.split("/").last() == "") {
target + "index.html"
} else {
target
}
} else { file-target }
if (path-cb != none) {
[#metadata( ( target: target,
path-src: path-cb(src),
path-target: path-cb(file-target)
) ) <link-load>]
}
link(target, body, ..attrs)
}
// bundle.typ
#document("/index.html", include("/index.typ"))
#context {
query(<link-load>)
.dedup(key: a => a.value.path-target)
.map(a => document(
// parse the path representation to extract it as a string
repr(a.value.path-target).slice(6, -2),
include(a.value.path-src)
))
.join()
}
// index.typ
#inclink("./page1/")[Page 1] // Generates out/page1/index.html from src/page1/index.typ
This works properly, but it has the issue of consuming an iteration for every layer deep I need to find links. Every page is 2 click away from the homepage so that isn’t a problem in itself. The problem is that the deepest documents now only have 3 iterations to converge, which fails occasionally. The issue would be even worse on a more complex website or with more complex documents. In my case, increasing the limit to 6 would be sufficient.
I know the intended way to use the bundle feature is to declare every document explicitly and use labels to link to them, but I find that having a 1-1 correspondence to the filesystem is more convenient. It also makes it easier to export only parts of the site.