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
 
(18 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,
-- 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 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á editores(es)colaboradores para o início da referência
local editorcontributor = frame:callParserFunction{ name = '#show', args = { target, '?Has editorcontributor#', 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 OU pelo editoragentes OU pelo título
iflocal #creator >agents= 1 then{}
if #creator >= 1 or #contributor >= 1 then
-- creator = string.gsub( creator, '(,%s%d%d%d%d%-?%d-)', '')
if string.match(creator creator,~= '^(.*),') then
creator = stringtable.matchinsert(agents, creator, '^(.*),') -- Assiscomo criador vem do campo 1XX, Machadonão há mais de, 1839-1908um 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( creatorv, '^(.*,.*)%s%(,') then
-- 'Assis, Machado de, 1839-1908' > 'Assis, Machado de'
agents[k] = string.match( v, '^(.*,.*),')
end
else end
if string.match( creator, '^(.*)%s%(') then
 
creator = string.match( creator, '^(.*)%s%(') -- Tolkien, J. R. R. (John Ronald Reuel), 1892-1973
for k, v in pairs(agents) do
if string.match( v, '^(.*)%s%(') then
creator = string.match( creator, '^(.*)%s%(') -- 'Tolkien, J. R. R. (John Ronald Reuel), 1892-1973' > 'Tolkien, J. R. R.'
agents[k] = string.match( v, '^(.*)%s%(')
end
end
creator = frame:callParserFunction{ name = '#regex', args = { creator, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }
reference = creator .. '. <b>' .. title .. '</b>. '
elseif #editor >= 1 then
editor = frame:callParserFunction{ name = '#regex', args = { editor, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }
reference = editor .. ' (Org.). <b>' .. title .. '</b>. '
else
reference = string.gsub( title, '^(.-%s)', '<span style="text-transform: uppercase;">%1</span>') .. '. '
 
local agentStr = table.concat(agents, "; ")
creatoragentStr = frame:callParserFunction{ name = '#regexrreplace', args = { creatoragentStr, '/(^.*?,)|(;.*?,)/', '<span style="text-transform: uppercase;">$1$2</span>' } }
reference = creatoragentStr .. '. <b>' .. title .. '</b>. '
 
else
-- Entrada pelo título
editorreference = frame:callParserFunction{string.gsub( name = '#regex', args = { editortitle, '/(^.*?,)|(;.*?,-%s)/', '<span style="text-transform: uppercase;">$%1$2</span>'. } }')
end
-- Entrada e título definidos
-- 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
Usuário anônimo

Menu de navegação