note_id = '"table_note_res_'..result_local..rand_val..'"' -- Identifier
note_text = note_res_local
else
-- It does point to another result note
note_ref = respre..'res_'..note_res_local
note_id = '"table_note_res_'..note_res_local..rand_val..'"' -- Identifier
note_text = Args['note_res_'..note_res_local]
end
-- Check whether it is already printed
if not note_id_list[note_ref] then
-- Print it
note_id_list[note_ref] = note_id
note_res_string = note_res_string .. :expandTemplate{ title = 'efn', args = { group='lower-alpha', name=note_id, note_text} }
else
-- Refer to it
note_res_string = note_res_string .. :extensionTag{ name = 'ref', args = { group = 'lower-alpha', name = note_id} }
end
end
end
-- Get text
local text_result = Args[respre..'text_'..result_local] or ''
if text_result:match('fbmulticomp') then
ii_fw = 'padding:0;' .. ii_fw
if text_result:match('fbmulticompefn') then
notes_exist = true
end
end
text_field_result = '| |'..text_result..note_res_string..'\n'
-- See whether it is needed (only when blank for all entries)
if results_defined then table.insert(t,text_field_result) end
end
end  
-- Insert match row if needed
if match_table then
local legs = tonumber(Args['legs']) or 1
-- Add empty cell
table.insert(t,'|| \n')  
-- Now include note to match results if needed
for jj=top_pos,N_teams do
team_code_jj = team_list[jj]
if ii == jj then
-- Nothing
else
for l=1,legs do
local m = (legs == 1) and 'match_' or 'match' .. l .. '_'
local match_note = Args[m..team_code_ii..'_'..team_code_jj..'_note']
if match_note then
notes_exist = true
-- Only when it exist
-- First check for existence of reference for note
if not (Args['note_'..match_note] or Args[m..match_note..'_note']) then
-- It's the entry
note_id = '"table_note_'..team_code_ii..'_'..team_code_jj..rand_val..'"' -- Add random end for unique ID if more tables are present on article (which might otherwise share an ID)
note_id_list[team_code_ii..'_'..team_code_jj] = note_id  
note_string = :expandTemplate{ title = 'efn', args = { group='lower-alpha', name=note_id, match_note} }
else
-- Check for existence elsewhere
note_local_num = team_list[match_note] or ii_end + 1
if note_id_list[match_note] or ((note_local_num >= ii_start) and (note_local_num <= ii_end)) then
-- It exists
note_id = '"table_note_'..match_note..rand_val..'"' -- Identifier
note_string = :extensionTag{ name = 'ref', args = { group = 'lower-alpha', name = note_id} }
else
-- Now define the identifier for this
note_id = '"table_note_'..match_note..rand_val..'"' -- Add random end for unique ID
note_id_list[match_note] = note_id
-- Call refn template
note_string = :expandTemplate{ title = 'efn', args = { group='lower-alpha', name=note_id, Args['note_'..match_note]} }
end
end  
-- Now append this to the match result string
Args[m..team_code_ii..'_'..team_code_jj] = (Args[m..team_code_ii..'_'..team_code_jj] or '')..note_string
end
end
end
end  
-- Add rest of match row
t = p_matches.row(t,Args,N_teams,team_list,ii,ii_show,legs)
end  
-- Now, if needed, insert a split (solid line to indicate split in standings, but only when it is not at the last shown position)
if Args['split'..ii] and (ii<ii_end) then
-- Base size on N_cols (it needs 2*N_cols |)
table.insert(t,'|-\n')
table.insert(t,string.rep('|',2*N_cols)..'\n')
end
end  
-- Close table
table.insert(t, '|}')  
-- Get info for footer
local update = Args['update'] or 'unknown'
local start_date = Args['start_date'] or 'unknown'
local source = Args['source'] or (title_source == true and '')
or :expandTemplate{ title = 'citation needed', args = { reason='No source parameter defined', date=os.date('%B %Y') } }
local class_rules = Args['class_rules'] or nil  
-- Create footer text
-- Date updating
local matches_text = Args['matches_text'] or 'ஆட்டம்(கள்)'
if string.lower(update)=='complete' then
-- Do nothing
elseif update=='' then
-- Empty parameter
table.insert(t_footer,'Updated to '..matches_text..' played on unknown. ')  
elseif string.lower(update)=='future' then
-- Future start date
table.insert(t_footer,'முதலாவது '..matches_text..' '..start_date.. ' அன்று விளையாடப்படும். ')
else
table.insert(t_footer,''..update..' '..matches_text..' இற்றைப்படுத்தப்பட்டது. ')
end  
-- Stack footer or not
local footer_break = yesno(Args['stack_footer'] or 'no') and true or false  
-- Variable for linebreak
local stack_string = '
'  
if footer_break and (not (string.lower(update)=='complete')) then table.insert(t_footer,stack_string) end  
if source ~= '' then
table.insert(t_footer,'மூலம்: '..source)
end
if class_rules and full_table and show_class_rules then
if (#t_footer > 0) then table.insert(t_footer,'
') end
table.insert(t_footer,'வகைப்பாட்டிற்கான விதிகள்: '..class_rules)
end  
-- Now for the named status
local status_exist = false
local status_string = ''
local curr_letter
for jjj = 1,mw.ustring.len(t_status.letters) do
curr_letter = mw.ustring.upper(mw.ustring.sub(t_status.letters,jjj,jjj))
if t_status.called[curr_letter] then
if (footer_break and status_exist) then
status_string = status_string..stack_string
end
if t_status.position == 'before' then
status_string = status_string..'<span>'..string.lower(curr_letter)..' &ndash;</span> '..t_status.code[curr_letter]..'; '
else
status_string = status_string..'<span>('..curr_letter..')</span> '..t_status.code[curr_letter]..'; '
end
status_exist = true
end
end
-- Now if it contains entries the '; ' needs to be removed
if status_exist then
if (#t_footer > 0) then table.insert(t_footer,'
') end
status_string = mw.ustring.sub(status_string,1,mw.ustring.len(status_string)-2)
table.insert(t_footer,status_string)
end  
-- Add notes (if applicable)
if notes_exist then
if (#t_footer > 0) then table.insert(t_footer,'
') end
table.insert(t_footer,'குறிப்புகள்:')
-- As reflist size text
t_footer = '<div>'..table.concat(t_footer)..'</div>'
t_footer = t_footer..:expandTemplate{ title = 'notelist', args = { group='lower-alpha'} }
else
-- As reflist size text
t_footer = '<div>'..table.concat(t_footer)..'</div>'
end  
-- Add footer to main text table
table.insert(t,t_footer)  
-- Rewrite anchor links
for k=1,#t do
if t[k]:match('%[%[#[^%[%]]*%|') then
t[k] = mw.ustring.gsub(t[k], '(%[%[)(#[^%[%]]*%|)', '%1' .. baselink .. '%2')
end
end  
-- Generate tracking
if not Args['notracking'] then
local getTracking = require('Module:Sports table/argcheck').check
local warning_categories, tracking_categories = getTracking(Args, :getParent.args)
if #warning_categories > 0 then
if :preprocess( "" ) == "" then
for k=1,#warning_categories do
warning_categories[k] = mw.ustring.gsub(warning_categories[k], '^%[%[Category:Pages using sports table with (.*)|(.*)%]%]$', '<div>Warning: %1 = %2</div>')
end
end
end
for k=1,#warning_categories do
table.insert(t, warning_categories[k])
end
for k=1,#tracking_categories do
table.insert(t, tracking_categories[k])
end  
if(Args['showteam'] == nil) then
local getWarnings = require('Module:Sports table/totalscheck').check
local total_warnings = getWarnings(Args, team_list, ii_start, ii_end)
if #total_warnings > 0 then
if :preprocess( "" ) == "" then
for k=1,#total_warnings do
table.insert(t, '<div>Possible problem: ' .. total_warnings[k] .. '</div>')
end
end
end
end
else
table.insert(t, '')
end  
if Args['float'] then
return :expandTemplate{ title = 'stack begin', args = {clear = 'true', margin = '1', float = Args['float']} }
.. templatestyles .. '\n' .. table.concat(t) .. :expandTemplate{ title = 'stack end'}
end  
return templatestyles .. '\n' .. table.concat(t)
end  
return p