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(' | 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%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 | |||
if date then | if date then | ||
return date; -- matched so return; | return date; -- matched so return; | ||
end | end |