Modul:Infobox: Perbedaan revisi

Loncat ke navigasi Loncat ke pencarian
343 bita ditambahkan ,  12 Juli 2021 16.56
fix for {{infobox}} with no input args generating an empty <table class="infobox"></table> per talk page
Mediawiki>Hidayatsrf
 
Mediawiki>Frietjes
(fix for {{infobox}} with no input args generating an empty <table class="infobox"></table> per talk page)
Baris 5: Baris 5:
local empty_row_categories = {}
local empty_row_categories = {}
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false


local function fixChildBoxes(sval, tt)
local function fixChildBoxes(sval, tt)
Baris 56: Baris 57:
else
else
return sval
return sval
end
end
-- Cleans empty tables
local function cleanInfobox()
root = tostring(root)
if has_rows == false then
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
end
end
end
end
Baris 94: Baris 103:
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
root
root
:tag('tr')
:tag('tr')
Baris 115: Baris 125:
category_in_empty_row_pattern, ''
category_in_empty_row_pattern, ''
):match('^%S') then
):match('^%S') then
has_rows = true
local row = root:tag('tr')
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
row:addClass(rowArgs.rowclass)
Baris 147: Baris 158:
if not args.title then return end
if not args.title then return end


has_rows = true
root
root
:tag('caption')
:tag('caption')
Baris 159: Baris 171:
if not args.above then return end
if not args.above then return end


has_rows = true
root
root
:tag('tr')
:tag('tr')
Baris 173: Baris 186:
if not args.below then return end
if not args.below then return end


has_rows = true
root
root
:tag('tr')
:tag('tr')
Baris 187: Baris 201:
if subheaderArgs.data and
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
local row = root:tag('tr')
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
row:addClass(subheaderArgs.rowclass)
Baris 227: Baris 242:
if imageArgs.data and
if imageArgs.data and
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
 
has_rows = true
local row = root:tag('tr')
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
row:addClass(imageArgs.rowclass)
Baris 324: Baris 340:
if not args.name then return end
if not args.name then return end


has_rows = true
root
root
:tag('tr')
:tag('tr')
Baris 441: Baris 458:
renderEmptyRowCategories()
renderEmptyRowCategories()
renderTrackingCategories()
renderTrackingCategories()
cleanInfobox()


return loadTemplateStyles() .. tostring(root)
return loadTemplateStyles() .. root
end
end


Pengguna anonim

Menu navigasi