Modulo:Footnotes/anchor id list/data/pagipadasan: Paggiddiatan a nagbaetan dagiti rebision
Content deleted Content added
Lam-ang (tungtungan | aramid) Agpartuat iti pagipadasan a bersion para iti Modulo:Footnotes/anchor id list/data |
Lam-ang (tungtungan | aramid) Pinabaro manipud iti Module:Footnotes/anchor id list/data/958410539 |
||
Linia 1:
-- copied from Module:Ref info/data - maybe overkill here?
-- for this application
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
]]
Line 231 ⟶ 229:
local function add_stripped (list, name)
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
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); -- no hyphen▼
add_stripped (list, lead .. '-' .. tail); -- hyphen▼
elseif name:match ('^(.-)(%%%-)(.+)$') then -- %-▼
lead, c, tail = name:match ('^(.-)(%%%-)(.+)$');▼
add_stripped (list, lead .. '-' .. tail); -- hyphen▼
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]) --
end
end
|