Diferencia entre revisiones de «Módulo:Citas»

2217 bytes eliminados ,  8 sep 2022
sin resumen de edición
m (1 revisión importada)
wikitves>Techso01
Sin resumen de edición
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 917: Línea 852:
         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 1337: Línea 1270:
      
      
     local Quote = A['Quote'];
     local Quote = A['Quote'];
     local PostScript = A['PostScript'];
     local TransQuote = A['TransQuote'];
local PostScript = A['PostScript'];


     local LayURL = A['LayURL'];
     local LayURL = A['LayURL'];
Línea 1898: Línea 1832:
     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 ) .. TransError .. Format       
             Title = externallink( URL, Title, URL_origin, UrlAccess ) .. TransError .. Format       
             URL = "";
             URL = "";
             TieneURL = true;
             TieneURL = true;
Línea 2123: Línea 2057:
     if is_set(URL) then
     if is_set(URL) then
         URL = " " .. externallink( URL, nil, URLorigin );
         URL = " " .. externallink( URL, nil, URLorigin, UrlAccess );
     end
     end
      
      
Línea 2137: Línea 2071:
end     
end     


     if is_set(Quote) then
     if is_set(Quote) or is_set(TransQuote) 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 2148: Línea 2082:
           Quote:sub(-1,-1) == '!' then
           Quote:sub(-1,-1) == '!' then
           PostScript = ""
           PostScript = ""
         end
          end
         
         -- Eliminar comillas de TransQuote
        if (TransQuote:sub(1, 1) == '"' and TransQuote:sub(-1, -1) == '"') or
          (Quote:sub(1,1) == '«' and Quote:sub(-1,-1) == '»') then
TransQuote = TransQuote:sub(2, -2);
end
          
          
        -- No añadir el punto final a la cita si el campo TransQuote ya incluye un punto
        if TransQuote:sub(-1,-1) == '.' or TransQuote:sub(-1,-1) == '?' or
          TransQuote:sub(-1,-1) == '!' then
          PostScript = ""
          end
          Quote = Quote .. " " .. wrap( 'trans-quoted-title', TransQuote );
          TransQuote = wrap( 'trans-quoted-title', TransQuote );
         Quote = sepc .." " .. wrap( 'quoted-text', Quote );  
         Quote = sepc .." " .. wrap( 'quoted-text', Quote );  
     end
     end
Usuario anónimo
MediaWiki spam blocked by CleanTalk.