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 |
||
(24 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
local reference
-- Alvo definido
-- Definir se há criador(es) para o início da referência
local creator = frame:callParserFunction{ name = '#show', args = { target, '?Has creator#', link = 'none', valuesep = '; '} }
-- Definir se há
local
-- 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
if #creator >= 1 or #contributor >= 1 then
creator = string.gsub( creator, '(,%s.*|%s%(.*)', '')▼
if creator ~= '' then
creator = frame:callParserFunction{ name = '#regex', args = { creator, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }▼
end
editor = frame:callParserFunction{ name = '#regex', args = { editor, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }▼
reference = editor .. ' (Org.). <b>' .. title .. '</b>. '▼
else▼
for v in string.gmatch(contributor, "([^;]+)") do -- como colaborador vem do campo 7XX, pode haver mais de um valor
table.insert(agents, v)
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
-- '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, "; ")
▲
▲ else
-- Entrada pelo título
▲
end
-- Entrada e título definidos
Linha 80 ⟶ 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
|