Módulo:ABNT: mudanças entre as edições

lint
imported>Jaideraf
Sem resumo de edição
imported>Jaideraf
(lint)
 
function p.CreateReference( frame )
-- Define o alvo da referência: pode ser o primeiro parâmetro passado à
-- predefinição, o valor da query string "fullpagename"
-- (via UrlGetParameters) ou o título da página.
local target = frame:getParent().args[1]
local reference
if target == '' or target == nil then
target = mw.uri.decode( frame:callParserFunction( '#urlget', 'fullpagename' ) )
end
if target == '' or target == nil then
-- Definir se há colaboradores para o início da referência
local contributor = frame:callParserFunction{ name = '#show', args = { target, '?Has contributor#', link = 'none', valuesep = '; '} }
-- Definir o título e o subtítulo
local title = frame:callParserFunction{ name = '#show', args = { target, '?Display title of#', link = 'none' } }
title = string.gsub( title, '(:.*)', '<span style="font-weight: normal;">%1</span>')
local agents={}
if #creator >= 1 or #contributor >= 1 then
if creator ~= '' then
table.insert(agents, creator) -- como criador vem do campo 1XX, não há mais de um valor
end
 
for v in string.gmatch(contributor, "([^;]+)") do -- como colaborador vem do campo 7XX, pode haver mais de um valor
table.insert(agents, v)
end
for k, v in pairs(agents) do
if string.match( v, '^(.*,.*),') then
-- 'Assis, Machado de, 1839-1908' > 'Assis, Machado de'
agents[k] = string.match( v, '^(.*,.*),')
end
end
for k, v in pairs(agents) do
if string.match( v, '^(.*)%s%(') then
-- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'
agents[k] = string.match( v, '^(.*)%s%(')
end
end
 
for k, v in pairs(agents) do
agentStr = table.concat(agents, "; ")
if string.match( v, '^(.*,.*),') then
agentStr = frame:callParserFunction{ name = '#regex', args = { agentStr, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }
reference = agentStr ..-- '.Assis, <b>'Machado ..de, title1839-1908' ..> '</b>.Assis, Machado de'
agents[k] = string.match( v, '^(.*,.*),')
end
end
 
for k, v in pairs(agents) do
if string.match( v, '^(.*)%s%(') then
-- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'
agents[k] = string.match( v, '^(.*)%s%(')
end
end
 
local agentStr = table.concat(agents, "; ")
agentStr = frame:callParserFunction{ name = '#regex', args = { agentStr, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }
reference = agentStr .. '. <b>' .. title .. '</b>. '
 
else
-- Entrada pelo título
reference = string.gsub( title, '^(.-%s)', '<span style="text-transform: uppercase;">%1</span>. ')
end
-- Entrada e título definidos
Usuário anônimo