Module:Footnotes: Difference between revisions

m 1 revision imported
Editor1 (talk | contribs)
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 special_patterns = whitelist_module.special_patterns;
local DNB_special_patterns = whitelist_module.DNB_special_patterns;
local DNB_template_names = whitelist_module.DNB_template_names;
if 10 == namespace then
return ''; -- automatic form of |no-tracking=yes; TODO: is this too broad?
end


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 (special_patterns) do -- spin through the spcial patterns and try to match
        for _, pattern in ipairs(citeref_patterns) do                           -- load patterns for wrapper templates on this page
if anchor_id:match (pattern) then
          if anchor_id:match(pattern) then                                     -- spin through the special patterns and try to match
return '';
              return ''
end
          end
end
        end
 
 
for _, dnb_t in ipairs (DNB_template_names or {}) do -- getting desparate now, are there any DNB templates? DNB_template_names may be nil; empty table prevents script error
if template_list[dnb_t] then -- if the article has this DNB template
for _, pattern in ipairs (DNB_special_patterns) do -- spin through the DNB-specifiec wildcard patterns
if anchor_id:match (pattern) then -- and attempt a match
return ''; -- found a match
end
end
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


--use this version to show error messages
-- display based on args.show (no display by default)
-- return msg and '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or '';
    local display = args.show and 'inline' or 'none'
--use this version to hide error messages
    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 '';
return msg and '<span class="error harv-error" style="display: none; 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,
};
};