end
end
end  
if score_over_played then
points = '<span>' .. points .. ' / ' .. matches .. '</span>'
elseif disp_fractions then
if math.floor(points) ~= points then
if math.floor(points) > 0 then
points = math.floor(points) .. templatestyles .. '<span>&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
else
points = templatestyles .. '<span>&nbsp;</span><sup>1</sup>&frasl;<sub>2</sub>'
end
end
end  
-- Sonneborn–Berger score
if show_sb then
if (sb_iff_hth and hth_local == '&mdash;') or nosb then
sb_score = '&mdash;'
end
if sb_score == 0 then
local legs = tonumber(Args['legs']) or 1
for jj=1,N_teams do
local tj = Args['team' .. jj]
local tjpoints = win_points*Args['win_'..tj] + draw_points*Args['draw_'..tj] + loss_points*Args['loss_'..tj]
if ii ~= jj then
local match_str = Args['match_' .. team_code_ii .. '_' .. tj] or ''
for l=1,legs do
local gii = mw.ustring.match(match_str, '^%s*([^%+%s]*)%s*%+?')
if gii == '1' then
sb_score = sb_score + win_points*tjpoints
elseif gii == '½' then
sb_score = sb_score + draw_points*tjpoints
elseif gii == '0' then
sb_score = sb_score + loss_points*tjpoints
end
match_str = mw.ustring.gsub(match_str, '^%s*([^%+%s]*)%s*%+?', *) or *
end
end
end
end
end  
-- Some local vars
local hth_string
local tt_return = p_sub.hth(,Args,full_table,hth_id_list,nil,notes_exist,team_list,team_code_ii,ii_start,ii_end,rand_val)
hth_string = tt_return.str
hth_id_list = tt_return.list
notes_exist = tt_return.notes_exist  
-- Row building
if full_table and show_rating then
local rateii = Args['rating_'..team_code_ii] or ''
table.insert(t,'| |'..rateii..'\n') -- Rating
end
if show_played then
table.insert(t,'| |'..matches..'\n') -- Played
end
table.insert(t,'| | '..points..'\n') -- Points
if full_table then
if show_hth and hth_first then
table.insert(t,'| |'..(hth_local or '')..'\n') -- Head-to-head
end
if show_sb and sb_first then
table.insert(t,'| |'..sb_score..'\n') -- Sonneborn–Berger
end
if show_win then
if wdl_iff_hth and hth_local == '&mdash;' then
wins = '&mdash;'
end
table.insert(t,'| |'..wins..'\n') -- Won
end
if show_draw then
if wdl_iff_hth and hth_local == '&mdash;' then
draws = '&mdash;'
end
table.insert(t,'| |'..draws..'\n') -- Drew
end
if show_loss then
if wdl_iff_hth and hth_local == '&mdash;' then
losses = '&mdash;'
end
table.insert(t,'| |'..losses..'\n') -- Lost
end
if show_hth and not hth_first then
table.insert(t,'| |'..(hth_local or '')..'\n') -- Head-to-head if not first tiebreak
end
if show_sb and not sb_first then
table.insert(t,'| |'..sb_score..'\n') -- Sonneborn–Berger
end
for ecol=1,extra_cols do
local extraii = Args['extra'..ecol..'_'..team_code_ii] or ''
table.insert(t,'| |'..extraii..'\n') -- Extra
end
end  
return {t=t, notes_exist=notes_exist, hth_id_list=hth_id_list}
end  
function pp.status(Args)
-- Declare status options
-- ------------------------------------------------------------
-- NOTE: If you add to status_code, also add to status_called and status_letters!!
-- Or functionality will be compromised
-- ------------------------------------------------------------
local status_code, status_called = {}
status_code = { A='Advance to a further round', C='Champion', D='Disqualified',
E='Eliminated', G='Guest', H='Host', O='Play-off winner', P='Promoted', Q='Qualified to the phase indicated',
R='Relegated', T='Qualified, but not yet to the particular phase indicated',
X='?', Y='?', Z='?'}
status_called = { A=false, C=false, D=false, E=false, G=false, H=false, O=false, P=false,
Q=false, R=false, T=false, X=false, Y=false, Z=false}
local status_letters = 'ACDEGHOPQRTXYZ'  
-- Status position (before or after read and default)
local stat_pos_val = Args['status_pos'] or ''
local status_position = 'after' -- Default location
stat_pos_val = string.lower(stat_pos_val)
if stat_pos_val=='before' then
status_position = 'before'
elseif stat_pos_val=='after' then
status_position = 'after'
end
-- Read in custom status options
for l in mw.text.gsplit(status_letters, '') do
if Args['status_text_' .. l] then
status_code[l] = Args['status_text_' .. l]
end
end  
return {code=status_code, called=status_called, letters=status_letters, position=status_position}
end  
return pp