seesubst.lua
local sip = require 'pl.sip'
local stringx = require 'pl.stringx'
local res = {}
local s = [[
(@see pl.bonzo.dog)
remember about @see pl.bonzo
]]
local _gsub_patterns = {}
local function gsub (s,pat,subst,start)
    local fpat = _gsub_patterns[pat]
    if not fpat then
                                fpat = '('..sip.create_pattern(pat)..')'
        _gsub_patterns[pat] = fpat
    end
    return s:gsub(fpat,subst,start)
end
local mod = sip.compile '$v.$v'
local fun = sip.compile '$v.$v.$v'
for line in stringx.lines(s) do
    line = gsub(line,'@see $p',function(see,path)
        if fun(path,res) or mod(path,res) then
            local ret = ('[see %s](%s.%s.html'):format(path,res[1],res[2])
            if res[3] then
                return ret..'#'..res[3]..')'
            else
                return ret..')'
            end
        end
    end)
    print(line)
end