I'm starring at these few (slightly modified) lines from luadoc that are obviously building a filename with a full path. But I simply don't get it what happens in line 5.
The parameter filename
could be something like "myfile.lua".
function out_file (filename)
local h = filename
h = string.gsub(h, "lua$", "tex")
h = string.gsub(h, "luadoc$", "tex")
h = options.output_dir .. string.gsub (h, "^.-([%w_]+%.tex)$", "%1")
return h
end
What does happen in line 5?
%
is the escape character in a pattern, and `` in regex; that there are is no alternation in a pattern, and so forth. – Snead