Module:Infobox: Difference between revisions

m
61 revisions imported from templatewiki:Module:Infobox
(merge from sandbox; still some pages with odd infoboxes over the place because of Tidy)
m (61 revisions imported from templatewiki:Module:Infobox)
 
(14 intermediate revisions by 10 users not shown)
Line 2:
-- This module implements {{Infobox}}
--
 
local p = {}
 
Line 21:
if s:match(marker) then
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
end
if s:match(marker) then
Line 44 ⟶ 49:
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481
-- remove when [[:phab:T191516]] is fixed or OBE
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
return s
else
Line 124 ⟶ 136:
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:newline()
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
end
Line 164 ⟶ 175:
:css('text-align', 'center')
:cssText(args.belowstyle)
:newline()
:wikitext(fixChildBoxes(args.below,'td'))
end
Line 179 ⟶ 189:
addRow({
data = args['subheader' .. tostring(num)],
datastyle = args.subheaderstyle or args['subheaderstyle' .. tostring(num)],
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
Line 258 ⟶ 269:
local function renderTrackingCategories()
if args.decat ~= 'yes' then
if args.child == 'yes' and args.title then
if #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
if args.title then
root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')
end
ifelseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Category:Articles which use infobox templates with no data rows]]')
end
if args.child == 'yes' and args.title then
root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')
end
end
Line 274 ⟶ 286:
root
:addClass((args.subbox ~= 'yes') and 'infobox' or nil)
:addClass(args.bodyclass)