Module:Infobox: Difference between revisions
Appearance
m spacing |
support finding plainlist in infobox class fields |
||
Line 6: | Line 6: | ||
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 has_rows = false | ||
local lists = { | |||
plainlist_t = { | |||
patterns = { | |||
'^plainlist$', | |||
'%splainlist$', | |||
'^plainlist%s', | |||
'%splainlist%s' | |||
}, | |||
found = false, | |||
styles = 'Plainlist/styles.css' | |||
} | |||
-- TODO: hlist_t goes here when ready to be TStyled, plus relevant | |||
-- implementations below | |||
} | |||
local function has_list_class(args_to_check) | |||
for _, list in pairs(lists) do | |||
if not list.found then | |||
for _, arg in pairs(args_to_check) do | |||
for _, pattern in ipairs(list.patterns) do | |||
if mw.ustring.find(arg or '', pattern) then | |||
list.found = true | |||
break | |||
end | |||
end | |||
if list.found then break end | |||
end | |||
end | |||
end | |||
end | |||
local function fixChildBoxes(sval, tt) | local function fixChildBoxes(sval, tt) | ||
Line 112: | Line 142: | ||
if rowArgs.header and rowArgs.header ~= '_BLANK_' then | if rowArgs.header and rowArgs.header ~= '_BLANK_' then | ||
has_rows = true | has_rows = true | ||
has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass }) | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 130: | Line 162: | ||
) | ) | ||
end | end | ||
elseif rowArgs.data and rowArgs.data:gsub( | elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | ||
has_rows = true | has_rows = true | ||
has_list_class({ rowArgs.rowclass, rowArgs.class }) | |||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(rowArgs.rowclass) | row:addClass(rowArgs.rowclass) | ||
Line 167: | Line 199: | ||
has_rows = true | has_rows = true | ||
has_list_class({args.titleclass}) | |||
root | root | ||
:tag('caption') | :tag('caption') | ||
Line 174: | Line 208: | ||
:cssText(args.titlestyle) | :cssText(args.titlestyle) | ||
:wikitext(args.title) | :wikitext(args.title) | ||
end | end | ||
Line 180: | Line 215: | ||
has_rows = true | has_rows = true | ||
has_list_class({ args.aboveclass }) | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 195: | Line 232: | ||
has_rows = true | has_rows = true | ||
has_list_class({ args.belowclass }) | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 210: | Line 249: | ||
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 | has_rows = true | ||
has_list_class({ subheaderArgs.rowclass, subheaderArgs.class }) | |||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(subheaderArgs.rowclass) | row:addClass(subheaderArgs.rowclass) | ||
Line 252: | Line 293: | ||
has_rows = true | has_rows = true | ||
has_list_class({ imageArgs.rowclass, imageArgs.class }) | |||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(imageArgs.rowclass) | row:addClass(imageArgs.rowclass) | ||
Line 363: | Line 406: | ||
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) | local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) | ||
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then | if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then | ||
root:wikitext( | root:wikitext(require('Module:Italic title')._main({})) | ||
end | end | ||
end | end | ||
Line 410: | Line 453: | ||
local templatestyles = '' | local templatestyles = '' | ||
if args['templatestyles'] then templatestyles = frame:extensionTag{ | if args['templatestyles'] then | ||
templatestyles = frame:extensionTag{ | |||
name = 'templatestyles', args = { src = args['templatestyles'] } | name = 'templatestyles', args = { src = args['templatestyles'] } | ||
} | } | ||
Line 416: | Line 460: | ||
local child_templatestyles = '' | local child_templatestyles = '' | ||
if args['child templatestyles'] then child_templatestyles = frame:extensionTag{ | if args['child templatestyles'] then | ||
child_templatestyles = frame:extensionTag{ | |||
name = 'templatestyles', args = { src = args['child templatestyles'] } | name = 'templatestyles', args = { src = args['child templatestyles'] } | ||
} | } | ||
Line 422: | Line 467: | ||
local grandchild_templatestyles = '' | local grandchild_templatestyles = '' | ||
if args['grandchild templatestyles'] then grandchild_templatestyles = frame:extensionTag{ | if args['grandchild templatestyles'] then | ||
grandchild_templatestyles = frame:extensionTag{ | |||
name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | ||
} | } | ||
end | end | ||
local plainlist_templatestyles = '' | |||
if lists.plainlist_t.found then | |||
plainlist_templatestyles = frame:extensionTag{ | |||
name = 'templatestyles', args = { src = lists.plainlist_t.styles } | |||
} | |||
end | |||
return table.concat({ | return table.concat({ | ||
base_templatestyles, -- see function description | base_templatestyles, -- see function description | ||
templatestyles, | templatestyles, | ||
child_templatestyles, | child_templatestyles, | ||
grandchild_templatestyles | grandchild_templatestyles, | ||
plainlist_templatestyles | |||
}) | }) | ||
end | end | ||
Line 460: | Line 514: | ||
-- @deprecated next; target .infobox-<name> | -- @deprecated next; target .infobox-<name> | ||
:cssText(args.bodystyle) | :cssText(args.bodystyle) | ||
has_list_class({ args.bodyclass }) | |||
renderTitle() | renderTitle() |