求真百科歡迎當事人提供第一手真實資料,洗刷冤屈,終結網路霸凌。

變更

前往: 導覽搜尋

模块:Citation/CS1

增加 501 位元組, 3 年前
per EP 設定test_limit為7000000(參考en)
if position then
-- if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then -- nowiki, and math, or quote param and ref stripmarker stripmarkers (not an error condition) if ('nowiki' == capture or 'mathtemplatestyles' == capture ) then -- nowiki, math templatestyles stripmarker (not an error condition)allowed stripmarker = true; -- set a flag
elseif true == stripmarker and 'delete' == char then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
position = nil; -- unset
end
--[[--------------------------< P M I D >---------------------------------------------------------------------- Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This code checks the PMID to see that itcontains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued. 
]]
local function pmid(id)
local test_limit = 3000000032000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
if id:match("[^%d]") then -- if PMID has anything but digits err_cat = ' ' .. set_error( 'bad_pmid' ); -- set an error message else -- PMID is only digits local id_num = tonumber(id); -- convert id to a number for range testing if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries err_cat = ' ' .. set_error( 'bad_pmid' ); -- set an error message
end
end
local function pmc(id, embargo)
local test_limit = 60000007000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid local id_num; local text;
local textid_num = id:match ('^[Pp][Mm][Cc](%d+)$'); -- identifier with pmc prefix  if is_set (id_num) then add_maint_cat ('pmc_format'); else -- plain number without pmc prefix id_num = id:match ('^%d+$'); -- if here id is all digits end
if id:matchis_set ("[^%d]"id_num) then -- if PMC id_num has anything but digits err_cat = ' ' .. set_error( 'bad_pmc' ); -- set an error message else -- PMC is only digitsa value so test it local id_num = tonumber(idid_num); -- convert id id_num to a number for range testing if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries err_cat = ' ' .. set_error( 'bad_pmc' ); -- set an error message else id = tostring (id_num); -- make sure id is a string
end
else -- when id format incorrect
err_cat = ' ' .. set_error( 'bad_pmc' ); -- set an error message
end
if is_set (embargo) then -- is PMC is still embargoed?
text="[[" .table. concat ( -- still embargoed so no external link { make_wikilink (handler.link .. "|" .. , handler.label .. "]]:" .. ), handler.separator .. , id .. , err_cat }); -- still embargoed so no external link
else
text = external_link_id({link = handler.link, label = handler.label, -- no embargo date or embargo has expired, ok to link to article
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
end
text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. (inactive or '')
local handler = cfg.id_handlers['HDL'];
local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
code = #language_list -- reuse code as number of languages in the list
if 2 >= code then
name = table.concat (language_list, '及') -- insert '<space> <space>' between two language names
elseif 2 < code then
language_list[code] = '及' .. language_list[code]; -- prepend last name with '及<space>' name = table.concat (language_list, ' ') ; -- and concatenate with '<comma><space>' separators name = name:gsub ('、及', '及', 1);
end
return (" " .. wrap_msg ('language', name)); -- otherwise wrap with '(in ...)'
匿名用戶