Edición de «Módulo:Citas»
Puedes deshacer la edición. Antes de deshacer la edición, comprueba la siguiente comparación para verificar que realmente es lo que quieres hacer, y entonces publica los cambios para así efectuar la reversión.
Revisión actual | Tu texto | ||
Línea 280: | Línea 280: | ||
end | end | ||
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str }); | return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str }); | ||
end | |||
--[[--------------------------< H D L >------------------------------------------------------------------------ | |||
Formats an HDL with minor error checking. | |||
HDL names contain two parts: prefix and suffix separated by a forward slash. | |||
Prefix: character string using any character in the UCS-2 character set except '/' | |||
Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant | |||
This function checks a HDL name for: prefix/suffix. If the HDL name contains spaces, endashes, or, if it ends | |||
with a period or a comma, this function will emit a bad_hdl error message. | |||
HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and | |||
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely | |||
if ever used in HDLs. | |||
Query string parameters are named here: http://www.handle.net/proxy_servlet.html. query strings are not displayed | |||
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we | |||
have to detect the query string so that it isn't URL-encoded with the rest of the identifier. | |||
]] | |||
local function hdl (options) | |||
local id = options.id; | |||
local access = options.access; | |||
local handler = options.handler; | |||
local query_params = { -- list of known query parameters from http://www.handle.net/proxy_servlet.html | |||
'noredirect', | |||
'ignore_aliases', | |||
'auth', | |||
'cert', | |||
'index', | |||
'type', | |||
'urlappend', | |||
'locatt', | |||
'action', | |||
} | |||
local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$'); -- look for query string | |||
local found; | |||
if hdl then -- when there are query strings, this is the handle identifier portion | |||
for _, q in ipairs (query_params) do -- spin through the list of query parameters | |||
if param:match ('^' .. q) then -- if the query string begins with one of the parameters | |||
found = true; -- announce a find | |||
break; -- and stop looking | |||
end | |||
end | |||
end | |||
if found then | |||
id = hdl; -- found so replace id with the handle portion; this will be URL-encoded, suffix will not | |||
else | |||
suffix = ''; -- make sure suffix is empty string for concatenation else | |||
end | |||
local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect, | |||
prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access}) | |||
if nil == id:match("^[^%s–]-/[^%s–]-[^%.,]$") then -- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma | |||
set_message ('err_bad_hdl' ); | |||
options.coins_list_t['HDL'] = nil; -- when error, unset so not included in COinS | |||
end | |||
return text; | |||
end | end | ||
--[[--------------------------< N O R M A L I Z E _ L C C N >-------------------------------------------------- | --[[--------------------------< N O R M A L I Z E _ L C C N >-------------------------------------------------- | ||
Línea 367: | Línea 432: | ||
]] | ]] | ||
function pmid(id) | function pmid(id) | ||
local test_limit = | local test_limit = 36000000; -- update this value as PMIDs approach | ||
local handler = cfg.id_handlers['PMID']; | local handler = cfg.id_handlers['PMID']; | ||
local err_cat = ''; -- presume that PMID is valid | local err_cat = ''; -- presume that PMID is valid | ||
Línea 413: | Línea 478: | ||
]] | ]] | ||
function pmc(id, embargo) | function pmc(id, embargo) | ||
local test_limit = | local test_limit = 10000000; -- update this value as PMCs approach | ||
local handler = cfg.id_handlers['PMC']; | local handler = cfg.id_handlers['PMC']; | ||
local err_cat = ''; -- presume that PMC is valid | local err_cat = ''; -- presume that PMC is valid | ||
Línea 419: | Línea 484: | ||
local text; | local text; | ||
if id:match("[^%d]") then -- if PMC has anything but digits | if id:match("[^%d]") then -- if PMC has anything but digits | ||
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message | err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message | ||
Línea 597: | Línea 659: | ||
while true do | while true do | ||
pattern = pages:match("%[(%w | pattern = pages:match("%[([%w/:\.]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url " | ||
if nil == pattern then break; end -- no more urls | if nil == pattern then break; end -- no more urls | ||
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible | pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible | ||
Línea 855: | Línea 917: | ||
elseif k == 'DOI' then | elseif k == 'DOI' then | ||
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } ); | table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } ); | ||
elseif k == 'HDL' then | |||
table.insert( new_list, {handler.label, hdl( v ) } ); | |||
elseif k == 'LCCN' then | elseif k == 'LCCN' then | ||
table.insert( new_list, {handler.label, lccn( v ) } ); | table.insert( new_list, {handler.label, lccn( v ) } ); | ||
Línea 1273: | Línea 1337: | ||
local Quote = A['Quote']; | local Quote = A['Quote']; | ||
local PostScript = A['PostScript']; | |||
local LayURL = A['LayURL']; | local LayURL = A['LayURL']; | ||
Línea 1835: | Línea 1898: | ||
if is_set(Title) then | if is_set(Title) then | ||
if not is_set(TitleLink) and is_set(URL) then | if not is_set(TitleLink) and is_set(URL) then | ||
Title = externallink( URL, Title | Title = externallink( URL, Title ) .. TransError .. Format | ||
URL = ""; | URL = ""; | ||
TieneURL = true; | TieneURL = true; | ||
Línea 2060: | Línea 2123: | ||
if is_set(URL) then | if is_set(URL) then | ||
URL = " " .. externallink( URL, nil, URLorigin | URL = " " .. externallink( URL, nil, URLorigin ); | ||
end | end | ||
Línea 2074: | Línea 2137: | ||
end | end | ||
if is_set(Quote | if is_set(Quote) then | ||
-- Eliminar comillas de Quote | -- Eliminar comillas de Quote | ||
if (Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"') or | if (Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"') or | ||
Línea 2085: | Línea 2148: | ||
Quote:sub(-1,-1) == '!' then | Quote:sub(-1,-1) == '!' then | ||
PostScript = "" | PostScript = "" | ||
end | |||
Quote = sepc .." " .. wrap( 'quoted-text', Quote ); | Quote = sepc .." " .. wrap( 'quoted-text', Quote ); | ||
end | end |