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

Conteúdo deletado Conteúdo adicionado
teste
Sem resumo de edição
 
(12 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 2:
 
function p.CreateReference( frame )
-- Define o alvo da referência: pode ser o primeiro parâmetro passado à predefinição,
-- predefinição; o valor da query string "fullpagename" (via UrlGetParameters) ou o título da página.
-- (via UrlGetParameters); o parâmetro nomeado Page (via WSSearchFront);
local target = frame:getParent().args[1]
-- 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 newagents={}reference
-- Alvo definido
-- Definir se há criador(es) para o início da referência
local creator = 'Hitzler, Pascal' -- frame:callParserFunction{ name = '#show', args = { target, '?Has creator#', link = 'none', valuesep = '; '} }
-- Definir se há editores(es)colaboradores para o início da referência
local contributor = 'Krötzsch, Markus; Rudolph, Sebastian' -- 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>')
-- Condição: entrada pelopelos autor, pelo contribuidoragentes OU pelo título
local agents={}
local newagents={}
local newnewagents={}
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, creatorv)
end
for v in string.gmatch(contributor, "([^;]+)") do
table.insert(agents, v)
end
for v in pairs(agents) do
if string.match( v, '^(.*,.*),') then
v = string.match( v, '^(.*,.*),') -- Assis, Machado de, 1839-1908
table.insert(newagents, v)
end
end
for v in pairs(newagents) do
if string.match( v, '^(.*)%s%(') then
v = string.match( v, '^(.*)%s%(') -- Tolkien, J. R. R. (John Ronald Reuel), 1892-1973
table.insert(newnewagents, v)
end
end
 
for k, v in pairs(agents) do
agentstr = table.concat(newnewagents, "; ")
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'
v agents[k] = string.match( v, '^(.*,.*),') -- Assis, Machado de, 1839-1908
else end
end
reference = string.gsub( title, '^(.-%s)', '<span style="text-transform: uppercase;">%1</span>') .. '. '
 
for k, v in pairs(newagentsagents) do
if string.match( v, '^(.*)%s%(') then
v = string.match( v, '^(.*)%s%(') -- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'
agents[k] = string.match( v, '^(.*)%s%(')
end
end
 
agentstr local agentStr = table.concat(newnewagentsagents, "; ")
agentstr agentStr = frame:callParserFunction{ name = '#regexrreplace', args = { agentstragentStr, '/(^.*?,)|(;.*?,)/', '<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
Linha 100 ⟶ 104:
-- Verificar se há ISBN
local isbn = frame:callParserFunction{ name = '#show', args = { target, '?Has ISBN#', link = 'none' } }
isbn = string.match( isbn, '^%d+') or ''
 
if #isbn >= 1 then
isbn = frame:callParserFunction{ name = '#invoke:ConverterHyphenate', args = { 'ISBN', isbn, 'Sim' } }
reference = reference .. ' ISBN ' .. isbn .. '. '
end