Lua Filters at the very end of Document?

I have a question about lua filters for quarto.

I think what I want to do should be fairly simple, but I can't seem to figure it out.

I would like to, at the very end before rendering the document, do a simple substitution.

The substitution would be:
text = text:gsub("]\n#block%[\n#mi", "#v(0.5em)\n#mi")

I am not entirely sure how to add this to my lua filter. I currently have a lua filter that is working, but it checks things block by block. This would be across blocks, so I would think just a find and replace across the whole document would be fine.

Does anyone know how to do this?

Thanks

:waving_hand: @co1emi11er, I moved your question over to "Publishing your results" since thats a good place for Quarto questions.

It looks like you want to perform the substitution on Typst syntax. Depending on when that Typst syntax is written it may not be accessible to a Lua filter since Lua filters operate on the abstract syntax tree not the final .typ.

Can you give a bit more context? Can you share your .qmd and current filter?