Modul:Sports series: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
huruf kecil untuk pertandingan mendatang; hapus perataan teks rata tengah (text-align:center) |
konversi otomatis teks biasa "aet", "pso"/"pen" menjadi templat pada kolom agregat |
||
Baris 209:
-- Remove superscript tags and their contents
str = str:gsub('<sup.->.-</sup>', '')
-- Check for walkover-related strings (never shown in small text)
if str:lower():match("walkover") or str:lower():match("w%.o%.") or str:lower():match("w/o") then
return false
end
-- Replace wiki links with their display text or link text
Baris 216 ⟶ 221:
str = str:gsub("%b()", "")
-- Exit if string contains only en/em dash
if str == "—" or str == "–" then
return false
Baris 237 ⟶ 243:
end
-- Function to format the dashes and winning notes for aggregate/leg score parameters
local function format_score(s, noWrap)
if not s then return '' end -- Return empty string if input is nil
s = mw.ustring.gsub(s, '^%s*([%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')▼
local function format_dash(pattern)
s = mw.ustring.gsub(s, '^%s*(%[%[[^%[%]]*%|[%d%.]+)%s*%-%s*([%d%.]+)', '%1–%2')▼
end
s = mw.ustring.gsub(s, '^%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)', '%1–%2')▼
-- Format dashes
format_dash('%s*([%d%.]+)%s*[–—―‒−%-]%s*([%d%.]+)')
▲
▲
format_dash('%s*(%[[^%[%]%s]*%s+[%d%.]+)%s*[–—―‒−%-]%s*([%d%.]+)')
format_dash('%s*(%[%[[^%[%]]*%|[%d%.]+)%s*&[MmNn][Dd][Aa][Ss][Hh];%s*([%d%.]+)')
▲
-- Format winning notes in brackets
if noWrap then
s = mw.ustring.gsub(s, '(%(%d+%s*–%s*%d+)%s+[Pp]%.?[EeSs]?%.?[NnOo]?%.?%)', '%1 [[Adu penalti|a.p]])')
s = mw.ustring.gsub(s, '%([Aa]%.?[Ee]%.?[Tt]%.?%)', '([[Perpanjangan waktu (sepak bola)|p.w.]])')
else
s = mw.ustring.gsub(s, '(%(%d+%s*–%s*%d+)%s+[Pp]%.?[EeSs]?%.?[NnOo]?%.?%)', '<span class="nowrap">%1 [[Adu penalti|a.p]])</span>')
s = mw.ustring.gsub(s, '%([Aa]%.?[Ee]%.?[Tt]%.?%)', '<span class="nowrap">([[Perpanjangan waktu (sepak bola)|p.w.]])</span>')
end
s = mw.ustring.gsub(s, '%([Aa]%.?[Gg]?%.?[Rr]?%.?%)', '([[Peraturan gol tandang|p.g.t]])')
return s
end
Baris 343 ⟶ 368:
local disableAwayGoals = args.away_goals == 'n' or args.away_goals == 'no' or args.away_goals == '0' or args.away_goals == 'false' or args.away_goals == 'null'
local disableSmallText = args.small_text == 'n' or args.small_text == 'no' or args.small_text == '0' or args.small_text == 'false' or args.small_text == 'null'
local noWrap
local tableClass = 'wikitable'
Baris 350 ⟶ 376:
tableStyle = tableStyle .. ' width: 100%;'
end
if noWrap then
▲ if args.nowrap and (args.nowrap == 'y' or args.nowrap == 'yes' or args.nowrap == '1' or args.nowrap == 'true') then
tableStyle = tableStyle .. ' white-space: nowrap;'
end
Baris 504 ⟶ 530:
local cleanAggregate = cleanScore(aggregateScore)
-- Format and rewrite anchor links for aggregate score
aggregateScore = format_score(aggregateScore, noWrap)
if baselink ~= '' then
aggregateScore = rewriteAnchorLinks(aggregateScore, baselink)
Baris 558 ⟶ 584:
-- Create aggregate score cell with conditional styling
local aggregateStyle = ''
if legs == 0 and not disableSmallText and aggregateScore ~= '' and checkSmallText(aggregateScore) then
aggregateStyle = 'font-size: ' .. smallFontSize .. '%;'
end
Baris 592 ⟶ 618:
else
-- Format and rewrite anchor links for leg scores
legScore = format_score(legScore, noWrap)
if baselink ~= '' then
legScore = rewriteAnchorLinks(legScore, baselink)
end
local legStyle = ''
if not disableSmallText and legScore ~= '' and checkSmallText(legScore) then
legStyle = 'font-size: ' .. smallFontSize .. '%;'
end
|