Content deleted Content added
sync |
be independent of order of evaluation of list |
||
Line 92:
['Citation-attribution'] = true,
}
local global_article_content = nil
local global_template_list = nil
local global_article_whitelist = nil
▲local anchor_id_list = {}; -- exported tables
local template_list = {};▼
local article_whitelist = {};▼
Line 108:
local function article_content_get ()
if global_article_content then return global_article_content end
end
global_article_content = article_content
return article_content
end
Line 697 ⟶ 698:
]]
local function template_list_add (template, template_list)
local template = template:match ('{{%s*(.-)[|}]'); -- keep the case of the template - this is different from template_name_get()
if template and not template:match ('^#') then -- found a template or magic word; ignore magic words
Line 723 ⟶ 724:
local function anchor_id_list_make ()
article_content_get (); -- attempt to get this article's content▼
if
return ''; -- no point in continuing
end
Line 734 ⟶ 738:
local find_pattern = '%f[{]{{[^{]';
local tstart, tend =
while tstart do
Line 743 ⟶ 747:
template_name = template_name_get (template); -- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox
template_list_add (template, template_list); -- add this template's name to the list
if data.known_templates_cs12 [template_name] then
Line 819 ⟶ 823:
end
tstart, tend =
end
mw.logObject (anchor_id_list, 'anchor_id_list');
Line 827 ⟶ 830:
mw.logObject (article_whitelist, 'article_whitelist');
▲ return anchor_id_list;
global_anchor_id_list = anchor_id_list
global_template_list = template_list
global_article_whitelist = article_whitelist
end
Line 839 ⟶ 845:
local function citeref_patterns_make()
if not
local citeref_patterns = {}
local template_patterns = whitelist.wrapper_template_patterns
for _, p in ipairs(template_patterns) do
for _, t in ipairs(p[1]) do -- loop through list of template wrappers
if
for _, pat in ipairs(p[2]) do
table.insert(citeref_patterns, pat)
Line 860 ⟶ 866:
]]
-- First create global_anchor_id_list, global_template_list, global_article_whitelist
anchor_id_list_make()
-- Then stuff them (and derived tables) into return table
return {
anchor_id_list =
article_whitelist =
template_list =
citeref_patterns = citeref_patterns_make() -- table of Lua patterns to search for citeref from wrappers
}
|