Editing Module:Footnotes/anchor id list

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
require('strict');
require('Module:No globals');
local data = mw.loadData ('Module:Footnotes/anchor id list/data');
local data = mw.loadData ('Module:Footnotes/anchor id list/data');
local whitelist = mw.loadData ('Module:Footnotes/whitelist');
local whitelist = mw.loadData ('Module:Footnotes/whitelist');
Line 73: Line 73:
}
}
local patterns_date = { -- normal lua patterns
local patterns_date = { -- normal lua patterns
-- '(%d%d%d%d–%d%d%d%d%l?)$', -- YYYY–YYYY four-digit year range at end (Season YYYY–YYYY); with or without dab
'(%d%d%d%d–%d%d%d%d%l?)$', -- YYYY–YYYY four-digit year range at end (Season YYYY–YYYY); with or without dab
'(%d%d%d%d)%D+(%d%d%d%d%l?)$', -- any range with four-digit years; with or without dab; not two captures
'^(%d%d%d%d–%d%d%l?)$', -- YYYY–YY two-digit year range; with or without dab
'^(%d%d%d%d–%d%d%l?)$', -- YYYY–YY two-digit year range; with or without dab
'^(c%. %d%d%d%d?%l?)$', -- three- or four-digit circa year; with or without dab
'^(c%. %d%d%d%d?%l?)$', -- three- or four-digit circa year; with or without dab
Line 158: Line 157:


local function date_get (template, aliases)
local function date_get (template, aliases)
local date;
local rvalue;
local rvalue;


Line 186: Line 186:
if rvalue then
if rvalue then
for _, pattern in ipairs (patterns_date) do -- spin through the recognized date formats
for _, pattern in ipairs (patterns_date) do -- spin through the recognized date formats
-- date = rvalue:match (pattern); -- attempt to extract year portion according to the pattern
date = rvalue:match (pattern); -- attempt to extract year portion according to the pattern
local date, date2 = rvalue:match (pattern); -- attempt to extract year portion according to the pattern; <date2> gets second year in any range
if date then
if date then
if date2 then -- when a second year
date = table.concat ({date, '–', date2}); -- build a date range
end
return date; -- matched so return;
return date; -- matched so return;
end
end

Please note that all contributions to Timeline of History may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Timeline of History:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: