Module:Infobox: Difference between revisions

Jump to navigation Jump to search
Remove <br> tag detection - Now that we're purged br lists from the wiki the detection will generate too many false positives to be useful. Better to enforce with editor guidelines and patrolling
No edit summary
(Remove <br> tag detection - Now that we're purged br lists from the wiki the detection will generate too many false positives to be useful. Better to enforce with editor guidelines and patrolling)
(One intermediate revision by the same user not shown)
Line 14: Line 14:
local CATEGORY_PARAM_CAPTION = "[[Category:Infoboxes using captions]]"
local CATEGORY_PARAM_CAPTION = "[[Category:Infoboxes using captions]]"
local CATEGORY_PARAM_NAME = "[[Category:Infoboxes using the name parameter]]"
local CATEGORY_PARAM_NAME = "[[Category:Infoboxes using the name parameter]]"
local CATEGORY_BR_TAGS = "[[Category:Infoboxes using br tags]]"
local CATEGORY_BR_TAGS_GAME = "[[Category:Infoboxes using br tags in game fields]]"
local CLASS_TOOLTIP = require("Module:Constants/class/tooltip")
local CLASS_TOOLTIP = require("Module:Constants/class/tooltip")
local DEFAULT_IMG_SIZE = "320x320px"
local DEFAULT_IMG_SIZE = "320x320px"
Line 37: Line 35:
if args.caption and args.caption ~= "" then
if args.caption and args.caption ~= "" then
categories = categories..CATEGORY_PARAM_CAPTION
categories = categories..CATEGORY_PARAM_CAPTION
end
for k, v in pairs(args) do
if string.find(v, "<br") then
h.warn("It appears the <code>%s</code> field may be using <code><nowiki><br></nowiki></code> tags to create a list. If so, please use [[Template:List]] or [[Template:Infobox Game Blocks]] instead. See [[:Category:Infoboxes using br tags]] for more information.", k)
categories = categories..CATEGORY_BR_TAGS
end
end
end
Line 92: Line 83:
return nil
return nil
end
end
 
games = utilsString.split(games)
if string.find(games, "<br") then
categories = categories..CATEGORY_BR_TAGS_GAME
games = utilsString.split(games, "<br>")
games = utilsTable.flatMap(games, utilsString._split("<br/>"))
else
games = utilsString.split(games)
end


local gameLinks = utilsTable.map(games, p.link)
local gameLinks = utilsTable.map(games, p.link)
Line 184: Line 168:
categories = categories..CATEGORY_INVALID_ARGS
categories = categories..CATEGORY_INVALID_ARGS
end
end
if listItems and string.find(listItems, "<br") then
if listItems then
h.warn("Using <code><nowiki><br></nowiki></code> tags to create lists is discouraged. Use commas instead, as this template treats them as delimiters. See [[Template:Infobox Game Blocks]] for more information.")
categories = categories..CATEGORY_BR_TAGS
listItems = utilsString.split(listItems, "<br>")
listItems = utilsTable.flatMap(listItems, utilsString._split("<br/>"))
elseif listItems then
listItems = utilsString.split(listItems, '%s*,%f[^,%d]%s*') -- %f[^,%d] is so we don't split numbers on their thousands separator (e.g., 1,500)
listItems = utilsString.split(listItems, '%s*,%f[^,%d]%s*') -- %f[^,%d] is so we don't split numbers on their thousands separator (e.g., 1,500)
end
if listItems then
table.insert(blocks, {
table.insert(blocks, {
game = game,  
game = game,  
Line 385: Line 362:
{
{
args = {"OoT, invalid game, TP"},
args = {"OoT, invalid game, TP"},
},
{
desc = "br tags are discouraged due to the poor HTML semantics.",
args = {"{{OoT}}<br>{{TP}}<br/>{{TotK}}"},
},
},
}
}

Navigation menu