Module:Citation/CS1/Identifiers: Difference between revisions
Jump to navigation
Jump to search
no edit summary
m (1 revision imported) |
No edit summary |
||
| Line 291: | Line 291: | ||
return lccn; | return lccn; | ||
end | |||
| Line 555: | Line 555: | ||
local err_flag; | local err_flag; | ||
local function is_extended_free (registrant, | local function is_extended_free (registrant, suffix) -- local function to check those few registrants that are mixed; identifiable by the doi suffix <incipit> | ||
if cfg.extended_registrants_t[registrant] then -- if this registrant has known free-to-read extentions | if cfg.extended_registrants_t[registrant] then -- if this registrant has known free-to-read extentions | ||
for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do -- loop through the registrant's incipits | for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do -- loop through the registrant's incipits | ||
if | if mw.ustring.find (suffix, '^' .. incipit) then -- if found | ||
return true; | return true; | ||
end | end | ||
| Line 590: | Line 590: | ||
end | end | ||
local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$'); -- registrant set when DOI has the proper basic form | local suffix; | ||
local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$'); -- registrant and suffix set when DOI has the proper basic form | |||
local registrant_err_patterns = { -- these patterns are for code ranges that are not supported | local registrant_err_patterns = { -- these patterns are for code ranges that are not supported | ||
'^[^1-3]%d%d%d%d%.%d+$', -- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999 | '^[^1-3]%d%d%d%d%.%d+$', -- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999 | ||
'^[^1- | '^[^1-7]%d%d%d%d$', -- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999 | ||
'^[^1-9]%d%d%d%.%d+$', -- 4 digits with subcode (0xxx); accepts: 1000–9999 | '^[^1-9]%d%d%d%.%d+$', -- 4 digits with subcode (0xxx); accepts: 1000–9999 | ||
'^[^1-9]%d%d%d$', -- 4 digits without subcode (0xxx); accepts: 1000–9999 | '^[^1-9]%d%d%d$', -- 4 digits without subcode (0xxx); accepts: 1000–9999 | ||
| Line 622: | Line 623: | ||
options.coins_list_t['DOI'] = nil; -- when error, unset so not included in COinS | options.coins_list_t['DOI'] = nil; -- when error, unset so not included in COinS | ||
else | else | ||
if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, | if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then -- |doi-access=free not set and <registrant> is known to be free | ||
set_message ('maint_doi_unflagged_free'); -- set a maint cat | set_message ('maint_doi_unflagged_free'); -- set a maint cat | ||
end | end | ||
| Line 709: | Line 710: | ||
]] | ]] | ||
local function isbn ( | local function isbn (options_t) | ||
local isbn_str = | local isbn_str = options_t.id; | ||
local ignore_invalid = | local ignore_invalid = options_t.accept; | ||
local handler = | local handler = options_t.handler; | ||
local year = options_t.Year; -- when set, valid anchor_year; may have a disambiguator which must be removed | |||
local function return_result (check, err_type) -- local function to handle the various returns | local function return_result (check, err_type) -- local function to handle the various returns | ||
| Line 721: | Line 723: | ||
else -- here when not ignoring | else -- here when not ignoring | ||
if not check then -- and there is an error | if not check then -- and there is an error | ||
options_t.coins_list_t['ISBN'] = nil; -- when error, unset so not included in COinS | |||
set_message ('err_bad_isbn', err_type); -- set an error message | set_message ('err_bad_isbn', err_type); -- set an error message | ||
return ISBN; -- return id text | return ISBN; -- return id text | ||
| Line 727: | Line 729: | ||
end | end | ||
return ISBN; -- return id text | return ISBN; -- return id text | ||
end | |||
if year and not ignore_invalid then -- | |||
year = year:match ('%d%d%d%d?'); -- strip disambiguator if present | |||
if year and (1965 > tonumber(year)) then | |||
set_message ('err_invalid_isbn_date'); -- set an error message | |||
return internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect, | |||
prefix = handler.prefix, id = isbn_str, separator = handler.separator}); | |||
end | |||
end | end | ||