Module:Footnotes/anchor id list/data explained

-- copied from Module:Ref info/data - maybe overkill here?-- for this application make lists from the redirect lists and force all template names first character uppercase

require('strict');

----------------------------< C S 1 _ T E M P L A T E _ P A T T E R N S >------------------------------------

These are patterns for cs1 templates and their redirects. These patterns exclude redirects that are vcite-likewhich redirects should be deleted because vcite is not cs1.

local cs1_template_patterns =

----------------------------< C S 2 _ T E M P L A T E _ P A T T E R N S >------------------------------------

These are patterns for cs2 templates redirects.

local cs2_template_patterns =

----------------------------< V C I T E _ T E M P L A T E _ P A T T E R N S >--------------------------------

These are patterns for Vcite-family templates and their redirects.

local vcite_template_patterns =

----------------------------< H A R V C _ T E M P L A T E _ P A T T E R N S >--------------------------------

These are patterns for the harvc template and its redirects.

local harvc_template_patterns =

----------------------------< C S 1 _ L I K E _ T E M P L A T E _ P A T T E R N S >--------------------------

These are patterns for miscellaneous templates and their redirects that 'look like' cs1 templates (begin with cite ...)

Because they 'look like' cs1 templates they are handled as if they were cs1 templates. These templates are NOTwrapper templates; names and dates are always to be extracted from the article instantiation of the template.

local cs1_like_template_patterns =

----------------------------< W I K I C I T E _ T E M P L A T E _ P A T T E R N S >--------------------------

These are patterns for the wikicite template and its redirects.

local wikicite_template_patterns =

----------------------------< A N C H O R _ T E M P L A T E _ P A T T E R N S >------------------------------

These are patterns for the anchor template and its redirects.

local anchor_template_patterns =

----------------------------< S F N _ W H I T E L I S T _ P A T T E R N S >----------------------------------

These are patterns for the anchor template and its redirects.

local sfn_whitelist_patterns =

--

local known_templates_cs12 = ; -- the exported tableslocal known_templates_vcite = ;local known_templates_harvc = ;local known_templates_wikicite = ;local known_templates_anchor = ;local known_templates_sfn_whitelist = ;

local function add_stripped (list, name) if not list[name] then list[name] = true; end end

local function pattern_convert (pattern, list) local lead, tail, c, l, name; local first_char_patterns = c = tostring (pattern:match ('%u')); -- tostring required because I don't know why; lua chokes complaining that c is not a string name = pattern:gsub ('^%[%a%a%]', c); -- replace bracketed first character [Xx] with selected character from the match if name:match ('(.-)%[(%a)(%a)%](.*)') then -- mixed case optional letters lead, c, l, tail = name:match ('(.-)%[(%a)(%a)%](.*)'); add_stripped (list, lead .. c .. tail); -- uppercase add_stripped (list, lead .. l .. tail); -- lowercase elseif name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$') then -- [%-]? lead, c, tail = name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$'); add_stripped (list, lead .. tail); -- neither char add_stripped (list, lead .. ' ' .. tail); -- space add_stripped (list, lead .. '-' .. tail); -- hyphen elseif name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$') then -- [%-]? lead, c, tail = name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$'); add_stripped (list, lead .. tail); -- no hyphen add_stripped (list, lead .. '-' .. tail); -- hyphen elseif name:match ('^([^%[]+)(%[%%%-%])(.+)$') then -- [%-] lead, c, tail = name:match ('^([^%[]+)(%[%%%-%])(.+)$'); add_stripped (list, lead .. ' ' .. tail); -- space add_stripped (list, lead .. '-' .. tail); -- hyphen elseif name:match ('^([^%?]+)(%%%-%?)(.+)$') then -- %-? lead, c, tail = name:match ('^([^%?]+)(%%%-%?)(.+)$'); add_stripped (list, lead .. tail); -- no hyphen add_stripped (list, lead .. '-' .. tail); -- hyphen elseif name:match ('^(.-)(%%%-)(.+)$') then -- %- lead, c, tail = name:match ('^(.-)(%%%-)(.+)$'); add_stripped (list, lead .. '-' .. tail); -- hyphen

elseif name:match ('^(.-)(.)%?(.*)$') then -- .? lead, c, tail = name:match ('^(.-)(.)%?(.*)$'); add_stripped (list, lead .. tail); -- no character add_stripped (list, lead .. c .. tail); -- character else add_stripped (list, name); -- no patterns so save as is end end

for _, t in ipairs do for _, pattern in ipairs (t[1]) do -- for each patern in *_template_patterns pattern_convert (pattern, t[2]) -- convert and store in known_templates_* end end

----------------------------< E X P O R T S >----------------------------------------------------------------

return