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

Ir para navegação Ir para pesquisar
sem sumário de edição
imported>Jaideraf
Sem resumo de edição
imported>Jaideraf
Sem resumo de edição
 
(4 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
 
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ítuloparâmetro nomeado Page (via daWSSearchFront); página.
-- ou o título da página.
local target = frame:getParent().args[1]
if target == '' or target == nil then
target = mw.uri.decode( frame:callParserFunction( '#urlget', 'fullpagename' ) )
end
if target == '' or target == nil then
target = frame:getParent().args.Page
end
if target == '' or target == nil then
target = mw.title.getCurrentTitle().prefixedText
end
local reference
-- Alvo definido
-- Definir se há criador(es) para o início da referência
-- 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
for v in string.gmatch(contributor, "([^;]+)") do -- como colaborador vem do campo 7XX, pode haver mais de um valor
if string.match( v, '^(.*)%s%(') then
table.insert(agents, v)
-- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'
end
agents[k] = string.match( v, '^(.*)%s%(')
for k, v in pairs(agents) doend
end
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
 
local agentStr = table.concat(agents, "; ")
agentStr = frame:callParserFunction{ name = '#regexrreplace', 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

Menu de navegação