Módulo:ABNT: mudanças entre as edições
Conteúdo deletado Conteúdo adicionado
Sem resumo de edição |
Sem resumo de edição |
||
(5 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
-- (via UrlGetParameters)
-- 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' ) )
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
Linha 17 ⟶ 22:
-- 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>')
Linha 23 ⟶ 28:
local agents={}
if #creator >= 1 or #contributor >= 1 then
if creator ~= '' then
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
if string.match( v, '^(.*)%s%(') then▼
-- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'▼
▲ end
end
end
else
end
-- Entrada e título definidos
Linha 110 ⟶ 118:
-- Retirar pontos repetidos
reference = string.gsub( reference, '%.%.', '.')
-- Exibe a referência
return reference
|