Can't get script working

Hello, I’m a new user (one day old) and I’d like to get a function working in my pages.
Let me know if this is not the spot to post these questions!

I added the following function within a page, and tried to call it with ${transform_calorie_text(...)}, which didn’t really work (function is still nil). Am I supposed to do something more to make the function available? Do I have to declare this somewhere else?

function transform_calorie_text(text)
    local result = {}

    for line in text:gmatch("[^\r\n]+") do
        local before, inside = line:match("^(.-)%((.-)%)$")
        if before and inside then
            inside = inside:gsub("c", "")
            before = before:gsub("%s*$", "")
            table.insert(result, before .. "\t=" .. inside)
        end
    end

    return table.concat(result, "\n")
end

if you haven’t already, run the System: Reload command

Nope, doesn’t help

it’s the “\t=” space-lua doesnt seems to recognise it.

you can see the red marker there, that means something is wrong with the syntax. If you wanted to add the literal tab character, try this:

table.insert(result, before .. string.char(9) .. "=" .. inside)

Ah, I didn’t realize. I tried this on another lua interpreter and it was ok. Thanks for the help!

Caused by bug. Fix PR-ed.

Just merged it, should be available on the edge builds soon.

that’s great! thanks a lot @mjf @zef