Let's say I'm writing a novel about Zatanna Zatara from the DC universe. I want to define something to automatically generate her backwards-speech spell thing. I should be able to do that. Something like:
% main.sub
\loadscript{util.lua}
\chapter{}
\zataracast{mosquitos be gone}!
-- util.lua
function macro.zataracast(content)
if content.type == text then
text = ''
for word of content.text:split(' ') do
if text.length > 0 then text += ' ' end
text += word:reverse()
done
content.text = text
end
end