The answer depends on what the body
actually means in this context.
For a string of text, it’s simply "text".len()
(or "".clusters().len()
for grapheme counting instead of UTF-8 bytes). For a content that consists only of plain text, it will be #[text].text.clusters().len()
.
For more complex examples, a more verbose solution is needed. A solution by @Eric for something similar mentioned here would be:
#let to-string(content) = {
if content.has("text") {
content.text
} else if content.has("children") {
content.children.map(to-string).join("")
} else if content.has("body") {
to-string(content.body)
} else if content == [ ] {
" "
}
}
#to-string[This _*cool*_ project] // => "This cool project"
I haven’t tested this, it might still miss some text, but it’s a great start nevertheless. So you would use it like this:
#let content-variable = [This _*cool*_ project]
#to-string(content-variable).clusters().len()
// Output: 17