No description of passing a function to string.gsub

The documentation of string.gsub, on the string library page, contains no description of what the function should do that you can pass as the third repl argument. The function takes a capture of the given pattern. If the function returns a string, the value returned is substituted back into the string, like so:

local s = "spoil this, spoil that, spoil everything!"
s = s:gsub("spoil", function(capture)
    return "[spoiler]" .. capture .. "[/spoiler]"
print(s) --> [spoiler]spoil[/spoiler] this, [spoiler]spoil[/spoiler] that, [spoiler]spoil[/spoiler] everything!

Currently, it is only mentioned that you can pass a function, not what it should take/return: