Modulo:Footnotes/anchor id list/data/pagipadasan: Paggiddiatan a nagbaetan dagiti rebision

Content deleted Content added
Agpartuat iti pagipadasan a bersion para iti Modulo:Footnotes/anchor id list/data
 
Linia 1:
-- copied from Module:Ref info/data - maybe overkill here?
-- for this application just make lists from the redirect lists and force all template names lowerfirst character case?uppercase
-- yes lowercase because Footnotes/anchor id list template_name_get() returns lowercase
--
-- TODO: but is that really the right thing to do?
 
require('Modulo:No globals');
 
--[[--------------------------< C S 1 _ T E M P L A T E _ P A T T E R N S >------------------------------------
Line 212 ⟶ 210:
These tables are created from the *_template_patterns tables. To make these tables, entries in the source tables
are evaluated to replace lua patterns with the appropriate characters to create names for the output tables.
 
First charqacter is always uppercase
 
For example:
Linia 218:
Cite arXiv
Cite arxiv
cite arXiv
cite arxiv
 
]]
Line 231 ⟶ 229:
 
local function add_stripped (list, name)
name = name:lower(); -- because Footnotes/anchor id list template_name_get() returns lowercase; TODO: is this the right thing to do?
if not list[name] then
list[name] = true;
Line 239 ⟶ 236:
 
local function pattern_convert (pattern, list)
local lead, tail, c, l, name;
local first_char_patterns = {
'^%[(%a)%a%]', -- leading character (usually uppercase)
Line 244 ⟶ 242:
}
c = tostring (pattern:match ('%u')); -- tostring() required because I don't know why; lua chokes complaining that c is not a string
for _, fcp in ipairs (first_char_patterns) do
local name = pattern:gsub (fcp, '^%1[%a%a%]', c); -- replace bracketed first character [Xx] with selected character from the match
if name:match ('(.-)%[(%a)(%a)%](.*)') then -- mixed case optional letters
local l;
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
elseifif name:match ('^([^.-)%[]+(%a)(%[ %%%-a)%])(.+*)$') then -- [mixed %-]case optional letters
lead, c, l, tail = name:match ('^(.-)%[^(%[]+a)(%[ %%%-a)%])(.+*)$');
add_stripped (list, lead .. ' 'c .. tail); -- spaceuppercase
add_stripped (list, lead .. '-'l .. tail); -- hyphenlowercase
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); -- noneither characterchar
add_stripped (list, lead .. c' ' .. tail); -- characterspace
add_stripped (list, lead .. l'-' .. tail); -- lowercasehyphen
else
elseif name:match ('^([^%[]+)(%[ %%%-%]%?)(.+)$') then -- [ %-]?
add_stripped (list, name); -- no patterns so save as is
lead, c, tail = name:match ('^([^%[]+)(%[ %%%-%]%?)(.+)$');
end
add_stripped (list, lead .. tail); -- neitherno charhyphen
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
 
ifelseif name:match ('^(.-)%[(%a)(%a.)%]?(.*)$') then -- mixed case optional letters.?
lead, c, l, tail = name:match ('^(.-)%[(%a)(%a.)%]?(.*)$');
add_stripped (list, lead .. tail); -- no hyphencharacter
add_stripped (list, lead .. c .. tail); -- uppercasecharacter
else
add_stripped (list, name); -- no patterns so save as is
end
end
Line 300 ⟶ 296:
}) do
for _, pattern in ipairs (t[1]) do -- for each patern in *_template_patterns
pattern_convert (pattern, t[2]) -- converconvert and store in known_templates_*
end
end