Module:Footnotes: Difference between revisions
EnWikiAdmin (talk | contribs) m 1 revision imported |
m 1 revision imported |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 40: | Line 40: | ||
local article_whitelist = anchor_id_list_module.article_whitelist; | local article_whitelist = anchor_id_list_module.article_whitelist; | ||
local template_list = anchor_id_list_module.template_list; | local template_list = anchor_id_list_module.template_list; | ||
local citeref_patterns = anchor_id_list_module.citeref_patterns | |||
local whitelist_module = mw.loadData ('Module:Footnotes/whitelist'); | local whitelist_module = mw.loadData ('Module:Footnotes/whitelist'); | ||
local whitelist = whitelist_module.whitelist; | local whitelist = whitelist_module.whitelist; | ||
local tally = anchor_id_list[anchor_id]; -- nil when anchor_id not in list; else a tally | local tally = anchor_id_list[anchor_id]; -- nil when anchor_id not in list; else a tally | ||
Line 84: | Line 78: | ||
end | end | ||
for _, pattern in ipairs(citeref_patterns) do -- load patterns for wrapper templates on this page | |||
if anchor_id:match(pattern) then -- spin through the special patterns and try to match | |||
return '' | |||
end | |||
end | |||
msg = 'no target: ' .. anchor_id; -- anchor_id not found | msg = 'no target: ' .. anchor_id; -- anchor_id not found | ||
mw.log(msg) | |||
if namespace == 10 and not args.show then -- do not generate error message in template namespace | |||
return '' | |||
end | |||
category = '[[Category:Harv and Sfn no-target errors]]'; | category = '[[Category:Harv and Sfn no-target errors]]'; | ||
elseif 1 < tally then | elseif 1 < tally then | ||
msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id; -- more than one anchor_id in this article | msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id; -- more than one anchor_id in this article | ||
mw.log(msg) | |||
if namespace == 10 and not args.show then -- do not generate error message in template namespace | |||
return '' | |||
end | |||
category = 0 == namespace and '[[Category:Harv and Sfn multiple-target errors]]' or ''; -- only categorize in article space | category = 0 == namespace and '[[Category:Harv and Sfn multiple-target errors]]' or ''; -- only categorize in article space | ||
return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category; | return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category; | ||
Line 112: | Line 105: | ||
category = 0 == namespace and category or ''; -- only categorize in article space | category = 0 == namespace and category or ''; -- only categorize in article space | ||
-- | -- display based on args.show (no display by default) | ||
local display = args.show and 'inline' or 'none' | |||
return msg and '<span class="error harv-error" style="display: '..display..'; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or ''; | |||
end | end | ||
Line 554: | Line 546: | ||
sfnm = sfnm, | sfnm = sfnm, | ||
sfnref = sfnref, | sfnref = sfnref, | ||
target_check = target_check, | |||
}; | }; |