Dear all,
as the title says, I would like to iterate over all cells of a table in a show rule. That is:
#show table: it => {
for child in it.children {
if (WHAT DO I NEED TO WRITE HERE TO CHECK IF CHILD IS A CELL?) {
/* Read the text from the body of the cell and do something with it. */
}
}
}
#table(
columns: (auto, auto, 1fr, auto, auto),
align: horizon,
table.header(
repeat: true
)[Head 1][Head 2][Head 3][Head 4][Head 5]
)[1][2][3][4][5]
What if condition should I use to check whether the child is a cell?
A few additional remarks:
- I am aware that I actually need to go recursively through all children to iterate over all cells. But that’s not my problem. My problem is that for the life of me I can’t find out how to check whether or not a child is a cell. Once I know that, implementing the recursion should be easy.
- Of course, I would be open to other solutions. For example, I tried to select all cells with a selector, but without avail. Either that’s not possible, or I have been too silly to find out the correct way. With other selectors, I had no problems, though. I’ll be happy with every method that enables me to iterate over all cells of a table in a
#showrule. It doesn’t need to be a recursive scan through all children. - There are some questions (along with answers) in this forum and elsewhere about how to automatically fill table cells with content (for example, from a CSV file). But I’d like to have it the other way around. I’d like to read the content of the cells.
Thank you very much in advance!