کاربر ناشناس
پودمان:Citation/CS1/en/Identifiers: تفاوت میان نسخهها
افزودن S2CID
جز (۱ نسخه واردشده) |
(افزودن S2CID) |
||
خط ۹۲۱: | خط ۹۲۱: | ||
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat; | prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat; | ||
end | end | ||
--[[--------------------------< S 2 C I D >-------------------------------------------------------------------- | |||
Format an S2CID, do simple error checking | |||
S2CIDs are sequential numbers beginning at 1 and counting up. This code checks the S2CID to see that it is only | |||
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically | |||
as more S2CIDs are issued. | |||
]] | |||
local function s2cid (id, access) | |||
local handler = cfg.id_handlers['S2CID']; | |||
local err_cat = ''; -- presume that S2CID is valid | |||
local id_num; | |||
local text; | |||
id_num = id:match ('^[1-9]%d*$'); -- id must be all digits; must not begin with 0; no open access flag | |||
if is_set (id_num) then -- id_num has a value so test it | |||
id_num = tonumber(id_num); -- convert id_num to a number for range testing | |||
if handler.id_limit < id_num then -- if S2CID is outside test limit boundaries | |||
err_cat = ' ' .. set_message ('bad_s2cid_err'); -- set an error message | |||
end | |||
else -- when id format incorrect | |||
err_cat = ' ' .. set_message ('bad_s2cid_err'); -- set an error message | |||
end | |||
text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect, | |||
prefix = handler.prefix, id = id:gsub ('%.%a%a', ''), separator = handler.separator, encode = handler.encode, access = access}) .. err_cat; | |||
return text; | |||
end | |||
خط ۱٬۰۸۸: | خط ۱٬۱۲۴: | ||
elseif k == 'PMID' then | elseif k == 'PMID' then | ||
table.insert( new_list, {handler.label, pmid( v ) } ); | table.insert( new_list, {handler.label, pmid( v ) } ); | ||
elseif k == 'S2CID' then | |||
table.insert( new_list, {handler.label, s2cid( v, handler.access ) } ); | |||
elseif k == 'SSRN' then | elseif k == 'SSRN' then | ||
table.insert( new_list, {handler.label, ssrn( v ) } ); | table.insert( new_list, {handler.label, ssrn( v ) } ); |