Module:Footnotes/anchor id list/sandbox: Difference between revisions

Content deleted Content added
correct comment
Tag: Reverted
Restored revision 1291059184 by Ahecht (talk): Did I break test 2?
Tags: Twinkle Undo Reverted
Line 2:
local data = mw.loadData ('Module:Footnotes/anchor id list/data');
local whitelist = mw.loadData ('Module:Footnotes/whitelist/sandbox');
local Lang_obj = mw.language.getContentLanguage(); -- used by template_name_gettemplate_list_add() to uppercase first letter of template name TODO: better way to do that?
 
local redirects_date = {
Line 386:
template_name = template_name:match ('^#invoke%s*:%s*(.+)'); -- get module name
local func_name = template:match ('^{{[^|}]+%|%s*([^/|}]*)'); -- get function name
mw.logObject(template_name,"module name")
mw.logObject(func_name,"func_name")
if template_name and func_name then -- valid module invocation
return template_name:gsub ('%s+$', '') .. ' ' .. func_name; -- ensure exactly one trailing whitespace between module and function name
Line 411 ⟶ 413:
return nil; -- could not get template name from (possibly corrupt) template; extraneous opening { mid template can cause this;
end;
mw.logObject(template_name,"template name")
template_name = template_name:gsub ('%s*$', ''); -- trim trailing whitespace; leading whitespace already removed
return Lang_obj:ucfirst (template_name); -- first character in template name must be uppercase (same as canonical template name) TODO: better way to do this?
Line 709 ⟶ 712:
list_add (anchor_id, anchor_id_list, true); -- add anchor ID to the list
end
end
end
 
 
--[[--------------------------< T E M P L A T E _ L I S T _ A D D >--------------------------------------------
 
makes a list of templates use in the article.
 
]]
 
local function template_list_add (template, template_list)
local template = template_name_get (template); -- despite the prior comment, this function and template_name_get() handle the case of the template identically
 
if template then -- found a template or magic word; ignore magic words
list_add (template, template_list); -- add to list with (unused) tally
end
end
Line 750 ⟶ 768:
break; -- template is nil for some reason (last template missing closing }} for example) so declare ourselves done
end
mw.logObject(template,"template")
template_name = template_name_get (template); -- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox
list_addtemplate_list_add (template_nametemplate, template_list); -- add this template's name to the list
 
if data.known_templates_cs12 [template_name] then