Modulo:Albero genealogico
Aspetto
Modulo in Lua per gestire le funzioni di {{Albero genealogico}}
local getArgs = require('Module:Arguments').getArgs
local signal_error = false
local p = {}
local output = {}
local function dump(t, ...)
local args = {...}
for _, s in ipairs(args) do
table.insert(t, s)
end
end
local cell_top = {
[' '] = '<td rowspan="2" colspan="2"><div style="width: 2em; height: 2em;"></div></td>',
['!'] = '<td rowspan="2" style="border-right: 1px solid black;"><div style="width: 1em; height: 2em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
[','] = '<td><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['v'] = '<td colspan="2" style="border-bottom: 1px solid black;"><div style="width: 2em; height: 1em;"></div></td>',
['.'] = '<td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['-'] = '<td colspan="2" style="border-bottom: 1px solid black;"><div style="width: 2em; height: 1em;"></div></td>',
[')'] = '<td rowspan="2" style="border-right: 1px solid black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['+'] = '<td style="border-right: 1px solid black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['('] = '<td style="border-right: 1px solid black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['`'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['^'] = '<td style="border-right: 1px solid black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
["'"] = '<td style="border-right: 1px solid black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
[':'] = '<td rowspan="2" style="border-right: 1px dashed black;"><div style="width: 1em; height: 2em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['F'] = '<td><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['V'] = '<td colspan="2" style="border-bottom: 1px dashed black;"><div style="width: 2em; height: 1em;"></div></td>',
['7'] = '<td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['~'] = '<td colspan="2" style="border-bottom: 1px dashed black;"><div style="width: 2em; height: 1em;"></div></td>',
['D'] = '<td rowspan="2" style="border-right: 1px dashed black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['%'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['C'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['L'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['A'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['J'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['Q'] = '<td rowspan="2" style="border-right: 1px dotted black;"><div style="width: 1em; height: 2em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['S'] = '<td><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['M'] = '<td colspan="2" style="border-bottom: 1px dotted black;"><div style="width: 2em; height: 1em;"></div></td>',
['T'] = '<td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['P'] = '<td colspan="2" style="border-bottom: 1px dotted black;"><div style="width: 2em; height: 1em;"></div></td>',
['H'] = '<td rowspan="2" style="border-right: 1px dotted black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['R'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['G'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['Y'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['W'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['Z'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['d'] = '<td rowspan="2" style="border-right: 1px dashed black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['}'] = '<td rowspan="2" style="border-right: 1px dashed black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['j'] = '<td colspan="2" style="border-bottom: 1px solid black;"><div style="width: 2em; height: 1em;"></div></td>',
['*'] = '<td style="border-right: 1px dashed black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['i'] = '<td style="border-right: 1px dashed black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['c'] = '<td style="border-right: 1px dashed black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['{'] = '<td style="border-right: 1px dashed black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['f'] = '<td rowspan="2" style="border-right: 1px solid black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
[']'] = '<td rowspan="2" style="border-right: 1px solid black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['y'] = '<td colspan="2" style="border-bottom: 1px dashed black;"><div style="width: 2em; height: 1em;"></div></td>',
['t'] = '<td style="border-right: 1px solid black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['#'] = '<td style="border-right: 1px solid black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['h'] = '<td style="border-right: 1px solid black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['e'] = '<td style="border-right: 1px solid black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['['] = '<td style="border-right: 1px solid black; border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['k'] = '<td rowspan="2" style="border-right: 1px dotted black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['r'] = '<td colspan="2" style="border-bottom: 1px solid black;"><div style="width: 2em; height: 1em;"></div></td>',
['a'] = '<td style="border-right: 1px dotted black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['q'] = '<td style="border-right: 1px dotted black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['l'] = '<td style="border-right: 1px dotted black; border-bottom: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['o'] = '<td rowspan="2" style="border-right: 1px solid black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['m'] = '<td colspan="2" style="border-bottom: 1px dotted black;"><div style="width: 2em; height: 1em;"></div></td>',
['b'] = '<td style="border-right: 1px solid black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['n'] = '<td style="border-right: 1px solid black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['p'] = '<td style="border-right: 1px solid black; border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['k2'] = '<td rowspan="2" style="border-right: 1px dotted black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['r2'] = '<td colspan="2" style="border-bottom: 1px dashed black;"><div style="width: 2em; height: 1em;"></div></td>',
['a2'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dashed #000001;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['q2'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dashed #000001;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['l2'] = '<td style="border-right: 1px dotted black; border-bottom: 1px dashed #000001;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>',
['o2'] = '<td rowspan="2" style="border-right: 1px dashed black;"><div style="width: 1em; height: 2em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['m2'] = '<td colspan="2" style="border-bottom: 1px dotted black;"><div style="width: 2em; height: 1em;"></div></td>',
['b2'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dotted #000001;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['n2'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dotted #000001;"><div style="width: 1em; height: 1em;"></div></td><td style="border-bottom: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['p2'] = '<td style="border-right: 1px dashed black; border-bottom: 1px dotted #000001;"><div style="width: 1em; height: 1em;"></div></td><td rowspan="2"><div style="width: 1em; height: 2em;"></div></td>'
}
local cell_bottom = {
[' '] = '',
['!'] = '',
[','] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['v'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['.'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['-'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
[')'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['+'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['('] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['`'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['^'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
["'"] = '<td><div style="width: 1em; height: 1em;"></div></td>',
[':'] = '',
['F'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['V'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['7'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['~'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['D'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['%'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['C'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['L'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['A'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['J'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['Q'] = '',
['S'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['M'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['T'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['P'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['H'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['R'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['G'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['Y'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['W'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['Z'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['d'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['}'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['j'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['*'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['i'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['c'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['{'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>',
['f'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
[']'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['y'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['t'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['#'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['h'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['e'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['['] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['k'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['r'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['a'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['q'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['l'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['o'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['m'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['b'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['n'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['p'] = '<td style="border-right: 1px solid black;"><div style="width: 1em; height: 1em;"></div></td>',
['k2'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['r2'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['a2'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['q2'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['l2'] = '<td style="border-right: 1px dotted black;"><div style="width: 1em; height: 1em;"></div></td>',
['o2'] = '<td><div style="width: 1em; height: 1em;"></div></td>',
['m2'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['b2'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td><td><div style="width: 1em; height: 1em;"></div></td>',
['n2'] = '<td colspan="2"><div style="width: 2em; height: 1em;"></div></td>',
['p2'] = '<td style="border-right: 1px dashed black;"><div style="width: 1em; height: 1em;"></div></td>'
}
function p.main(frame)
-- Convert all parameter trimming blank space e converting all positional parameter containing blank character (or empty)
-- to a single space. Return value for nomimal parameter containing only blank character is nil
local args = getArgs(frame, {
valueFunc = function (key, value)
if type(key) == "number" then
if value == nil then
return nil
else
value = mw.text.trim(value)
if value == '' then value = ' ' end
end
else
if value == '' then return nil end
end
return value
end
})
return p._main(args)
end
function p._main(args)
dump(output, '<tr style="height: 1px; text-align: center;">')
local pos = 1
local continue = true
local box_border_default = args['border'] or "2"
local box_style_default = args['boxstyle'] or ""
local box_colspan_default = args['colspan'] or "6"
local box_rowspan_default = args['rowspan'] or "2"
while continue do
local cell = args[pos]
if cell then
if cell_top[cell] then
dump(output, cell_top[cell])
else
content = args[cell]
if content ~= nil then
local border_width = args['border' .. "_" .. cell] or box_border_default
local style = args['boxstyle' .. "_" .. cell] or box_style_default
local colspan = args['colspan' .. "_" .. cell] or box_colspan_default
local rowspan = args['rowspan' .. "_" .. cell] or box_rowspan_default
dump(output, '<td colspan="', colspan, '" rowspan="', rowspan, '" style="border:',
border_width, 'px solid black;padding:0.2em;', style, '">', content, '</td>' )
else
dump(output, '<td colspan="', box_colspan_default, '" rowspan="', box_rowspan_default, '" style="border:',
box_border_default, 'px solid black;padding:0.2em;', box_style_default,
'"><strong class="error">Casella "', cell,
'" non definita</strong></td>')
signal_error = true
end
end
pos = pos +1
else
continue = false
end
end
dump(output, '</tr><tr style="height: 1px; text-align: center;">')
last = pos
for pos = 1, last do
local cell = args[pos]
if cell and cell_bottom[cell] then
dump(output, cell_bottom[cell])
end
end
dump(output, '</tr>')
for k, _ in pairs(cell_top) do
if k~="7" and args[k] then
signal_error = true
dump(output, '<div class="error">Il codice "' .. k .. '" non può essere usato come chiave di una cella</div>')
end
end
if signal_error and mw.title.getCurrentTitle().namespace == 0 then
dump(output, '[[Categoria:Errori di compilazione del template Albero genealogico]]')
end
return table.concat(output)
end
return p