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; o valor da query string "fullpagename"
-- (via UrlGetParameters); o parâmetro nomeado Page (via WSSearchFront);
local target = frame:getParent().args[1] ▼
-- ou o título da página.
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
-- Alvo definido
-- Definir se há criador(es) para o início da referência
local creator =
-- Definir se há
local contributor =
-- 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
local agents={}
▲ local newagents={}
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
▲ for v in string.gmatch(contributor, "([^;]+)") do
▲ end
for v in pairs(agents) do▼
if string.match( v, '^(.*,.*),') then▼
v = string.match( v, '^(.*,.*),') -- Assis, Machado de, 1839-1908▼
▲ 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▼
end▼
agentstr = table.concat(newnewagents, "; ")▼
agentstr = frame:callParserFunction{ name = '#regex', args = { agentstr, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }▼
▲ end
reference = string.gsub( title, '^(.-%s)', '<span style="text-transform: uppercase;">%1</span>') .. '. '▼
▲
agents[k] = string.match( v, '^(.*)%s%(')
▲
reference = agentStr .. '. <b>' .. title .. '</b>. '
▲ else
-- Entrada pelo título
▲
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:
reference = reference .. ' ISBN ' .. isbn .. '. '
end
|