Marvel Wiki
Sin resumen de edición
Sin resumen de edición
(No se muestran 4 ediciones intermedias del mismo usuario)
Línea 4: Línea 4:
 
---- //*** Functions for transforming pagenames of comics/episodes into desirable format ***// ----
 
---- //*** Functions for transforming pagenames of comics/episodes into desirable format ***// ----
   
  +
--------------------------------------------------------------------------------------------------
 
  +
-- returns transformed issue/episode number that can be used for sorting in categories as numbers, instead of text, including "point one" issues and "-1"/"negative" issues
-- devuelve el número de emisión/episodio transformado que puede utilizarse para clasificar en categorías como números, en lugar de texto, incluyendo las emisiones "punto uno" y las emisiones "-1"/"negativas".
 
 
function p.lua_padded_issue(issue)
 
function p.lua_padded_issue(issue)
local minus = '5'
+
local minus = '5'
local point_one = '00'
+
local point_one = '00'
local i = ''
+
local i = ''
local j = ''
+
local j = ''
local output = ''
+
local output = ''
local s1 = ''
+
local s1 = ''
local s2 = ''
+
local s2 = ''
  +
 
if not h.isempty(issue)
+
if not h.isempty(issue)
then
+
then
if issue == '½'
+
if issue == '½'
then issue = '0.5'
+
then issue = '0.5'
  +
end
end
 
  +
 
if string.find(issue, '%d+: ') ~= nil
+
s1, s2 = string.match( string.lower(issue), '(%d+)(%l)')--'(%d+)(%D+)')
  +
if not h.isempty( s2 ) --and s2 ~= '.'
then issue = string.match(issue, '(%d+): ')
 
  +
then issue = s1..'.'..s2
end
 
  +
end
 
  +
s1, s2 = string.match( string.lower(issue), '(%d+)(%l)')--'(%d+)(%D+)')
 
  +
if string.match(issue, '^%-*%d', 1) ~= nil --check if issue starts with number (including negative numbers like -1)
if not h.isempty( s2 ) --and s2 ~= '.'
 
  +
then
then issue = s1..'.'..s2
 
  +
-- -1 issues
end
 
  +
j = string.find(issue,"-",1,true)
 
  +
if not h.isempty(j)
if string.match(issue, '^%-*%d', 1) ~= nil --comprueba si el cómic comienza con un número (incluyendo números negativos como -1)
 
  +
then
then
 
  +
i = string.sub(issue,2,#issue)
-- -1 issues
 
j = string.find(issue,"-",1,true)
+
j = string.find(i,".",1,true)
if not h.isempty(j)
+
if not h.isempty(j)
  +
then minus = 5 - #string.sub(i,1,j-1)
then
 
  +
else minus = 5 - #i
i = string.sub(issue,2,#issue)
 
  +
end
j = string.find(i,".",1,true)
 
  +
else
if not h.isempty(j)
 
  +
i = issue
then minus = 5 - #string.sub(i,1,j-1)
 
  +
end
else minus = 5 - #i
 
  +
end
 
  +
-- point one issues
else
 
  +
j = string.find(i,".",1,true)
i = issue
 
  +
if not h.isempty(j)
end
 
  +
then
 
  +
point_one = string.sub(i,j+1,#i)
-- Cómics de punto uno
 
  +
if tonumber(point_one) == nil
j = string.find(i,".",1,true)
 
  +
then point_one = '99' -- for issues with letters after . instead of just numbers (for example, Amazing Spider-Man Vol 5 #16.HU)
if not h.isempty(j)
 
  +
end
then
 
point_one = string.sub(i,j+1,#i)
+
point_one = string.rep("0", 2-#point_one)..point_one
  +
i = string.sub(i,1,j-1)
if tonumber(point_one) == nil
 
  +
end
then point_one = '99' -- para cuestiones con letras después de . en lugar de sólo números (por ejemplo, Amazing Spider-Man Vol 5 #16.HU)
 
  +
end
 
point_one = string.rep("0", 2-#point_one)..point_one
+
output = minus..string.rep("0", 6-#i)..i..point_one
  +
else -- issue is not a number
i = string.sub(i,1,j-1)
 
  +
output = issue --'999999999'
end
 
  +
end
 
  +
end
output = minus..string.rep("0", 6-#i)..i..point_one
 
  +
else -- el cómic no es un número
 
  +
return output
output = issue --'999999999'
 
end
 
end
 
 
return output
 
 
end
 
end
   
  +
-- returns transformed volume/season number that can be used for sorting in categories as numbers, instead of text
--------------------------------------------------------------------------------------------------
 
-- devuelve el número de volumen/temporada transformado que puede utilizarse para clasificar en categorías como números, en lugar de texto
 
 
function p.lua_padded_volume(volume)
 
function p.lua_padded_volume(volume)
local output = ''
+
local output = ''
  +
 
if not h.isempty(volume)
+
if not h.isempty(volume)
then output = string.rep("0", 6-#volume)..volume
+
then output = string.rep("0", 6-#volume)..volume
end
+
end
  +
 
return output
+
return output
 
end
 
end
   
  +
-- returns transformed title, with replaced characters like ":" or "/" that can be used for names of files (for example, covers)
 
--------------------------------------------------------------------------------------------------
 
-- devuelve el título transformado, con caracteres sustituidos como ":" o "/" que pueden utilizarse para los nombres de los archivos (por ejemplo, portadas)
 
 
function p.lua_title_for_files(title)
 
function p.lua_title_for_files(title)
local output = title
+
local output = title
  +
 
output = string.gsub(output,'/',' ')
+
output = string.gsub(output,'/',' ')
output = string.gsub(output,':','')
+
output = string.gsub(output,':','')
output = string.gsub(output,'&','&')
+
output = string.gsub(output,'&','&')
output = string.gsub(output,''',"'")
+
output = string.gsub(output,''',"'")
   
return output
+
return output
 
end
 
end
   
  +
-- break down pagename of comics/episodes into parts - title, volume/season, issue/episode.
--------------------------------------------------------------------------------------------------
 
  +
---- Also returns transformed volume/season number and issue/episode number that can be used for sorting in categories as numbers, instead of text, including "point one" issues and "-1"/"negative" issues
-- desglosa el nombre de página de los cómics/episodios en partes: título, volumen/temporada, número/episodio.
 
  +
---- Also returns transformed title, with replaced characters like ":" or "/" that can be used for names of files (for example, covers)
---- También devuelve el número de volumen/temporada y el número de número/episodio transformados que se pueden utilizar para clasificar en categorías como números, en lugar de texto, incluyendo los números "punto uno" y los números "-1"/"negativos".
 
---- También devuelve el título transformado, con caracteres sustituidos como ":" o "/" que pueden utilizarse para los nombres de los archivos (por ejemplo, portadas)
 
 
function p.lua_get_title_volume_issue(pagename, pagetype)
 
function p.lua_get_title_volume_issue(pagename, pagetype)
local title = ''
+
local title = ''
local volume = ''
+
local volume = ''
local issue = ''
+
local issue = ''
local padded_issue = ''
+
local padded_issue = ''
local padded_volume = ''
+
local padded_volume = ''
local title_for_files = ''
+
local title_for_files = ''
local remainder_issue = ''
+
local remainder_issue = ''
local clean_issue = ''
+
local clean_issue = ''
  +
local j
local link_part1 = ''
 
  +
local k
local link_part2 = ''
 
  +
local design = require("Module:Design")
 
  +
if h.isempty(pagetype)
local j
 
  +
then pagetype = 'Vol'
local k
 
  +
end
local s
 
  +
 
  +
j,k = string.find(pagename, ' '..pagetype..' %d+ ')
if h.isempty(pagetype)
 
  +
if not h.isempty(j)
then pagetype = 'Vol'
 
  +
then
end
 
  +
title = string.sub(pagename, 1, j-1)
 
j,k = string.find(pagename, ' '..pagetype..' %d+ ')
+
issue = string.gsub(string.sub(pagename, k+1, #pagename), '#', '')
  +
j,k,volume = string.find(pagename, ' '..pagetype..' (%d+) ')
if not h.isempty(j)
 
  +
else
then
 
title = string.sub(pagename, 1, j-1)
+
j,k = string.find(pagename, ' #')
  +
if h.isempty(j)
issue = string.gsub(string.sub(pagename, k+1, #pagename), '#', '')
 
  +
then
j,k,volume = string.find(pagename, ' '..pagetype..' (%d+) ')
 
  +
j,k = string.find(pagename, ' '..pagetype..' %d+')
else
 
  +
if not h.isempty(j)
j,k = string.find(pagename, ' #')
 
  +
then
if h.isempty(j)
 
  +
title = string.sub(pagename, 1, j-1)
then
 
j,k = string.find(pagename, ' '..pagetype..' %d+')
+
volume = string.sub(pagename, j+#pagetype+2, k)
  +
else return ''
if not h.isempty(j)
 
  +
end
then
 
  +
else
title = string.sub(pagename, 1, j-1)
 
volume = string.sub(pagename, j+#pagetype+2, k)
+
title = string.sub(pagename, 1, j-1)
  +
issue = string.sub(pagename, k+1, #pagename)
else return ''
 
  +
volume = '1'
end
 
  +
end
else
 
  +
end
title = string.sub(pagename, 1, j-1)
 
  +
issue = string.sub(pagename, k+1, #pagename)
 
  +
if not h.isempty(issue) and tonumber(issue) == nil
volume = '1'
 
  +
then clean_issue, remainder_issue = string.match(issue, '(%d+)(%D+)')
end
 
end
+
end
 
if not h.isempty(issue) and tonumber(issue) == nil
 
then clean_issue, remainder_issue = string.match(issue, '(%d+)(%D+)')
 
end
 
 
if not h.isempty(title)
 
then
 
if not h.isempty(issue)
 
then
 
if pagetype == 'Temporada'
 
then link_part2 = 'E'..string.rep('0', 2-#issue)..issue
 
else
 
link_part1, link_part2 = string.match(issue, '(%d+): (.+)')
 
if h.isempty(link_part2)
 
then link_part2 = ' #'..issue
 
else link_part2 = design.span(': '..link_part2).italic
 
end
 
end
 
link_part1 = title..' '..pagetype..' '..volume..' '..issue
 
else
 
link_part1 = title..' '..pagetype..' '..volume
 
end
 
if pagetype == 'Temporada'
 
then
 
s = string.gsub(title, ' %(.+%)', '')
 
link_part2 = design.span(s).italic..' S'..volume..link_part2
 
else
 
if volume == '1'
 
then link_part2 = design.span(title).italic..link_part2
 
else link_part2 = design.span(title).italic..' ('..pagetype..'. '..volume..')'..link_part2
 
end
 
end
 
end
 
   
padded_volume = p.lua_padded_volume(volume)
+
padded_volume = p.lua_padded_volume(volume)
padded_issue = p.lua_padded_issue(issue)
+
padded_issue = p.lua_padded_issue(issue)
title_for_files = p.lua_title_for_files(title)
+
title_for_files = p.lua_title_for_files(title)
return { ['título'] = title,
+
return { ['title'] = title,
['volumen'] = volume,
+
['volume'] = volume,
['issue'] = issue,
+
['issue'] = issue,
['clean_issue'] = clean_issue or '',
+
['clean_issue'] = clean_issue or '',
['remainder_issue'] = remainder_issue or '',
+
['remainder_issue'] = remainder_issue or '',
['padded_volume'] = padded_volume,
+
['padded_volume'] = padded_volume,
['padded_issue'] = padded_issue,
+
['padded_issue'] = padded_issue,
  +
['title_for_files'] = title_for_files,
['filename'] = {
 
  +
['filename'] = {
['título'] = title_for_files,
 
['noissue'] = title_for_files..' '..pagetype..' '..volume,
+
['title'] = title_for_files,
['all'] = title_for_files..' '..pagetype..' '..volume..' '..issue,
+
['noissue'] = title_for_files..' '..pagetype..' '..volume,
  +
['all'] = title_for_files..' '..pagetype..' '..volume..' '..issue,
},
 
  +
},
['sortname'] = {
 
  +
['sortname'] = {
['título'] = p.lua_remove_the(title),
 
['noissue'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume,
+
['title'] = p.lua_remove_the(title),
['all'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume..' '.. padded_issue,
+
['noissue'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume,
  +
['all'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume..' '.. padded_issue,
},
 
  +
},
['link'] = {
 
  +
['noissue'] = title..' '..pagetype..' '..volume,
['part1'] = link_part1,
 
  +
['all'] = title..' '..pagetype..' '..volume..' '..issue,
['part2'] = link_part2,
 
  +
}
['all'] = h.Link(link_part1, link_part2),
 
},
 
['noissue'] = title..' '..pagetype..' '..volume,
 
['all'] = title..' '..pagetype..' '..volume..' '..issue,
 
}
 
 
end
 
end
   
   
  +
-- removes "The " from the start of pagename
--------------------------------------------------------------------------------------------------
 
-- elimina "El " del comienzo de pagename
 
 
function p.lua_remove_the(pagename)
 
function p.lua_remove_the(pagename)
if not h.isempty(pagename) and string.lower( string.sub(pagename, 1, 4) ) == 'the '
+
if not h.isempty(pagename) and string.lower( string.sub(pagename, 1, 4) ) == 'the '
then pagename = string.sub(pagename, 5, #pagename)
+
then pagename = string.sub(pagename, 5, #pagename)
end
+
end
return pagename
+
return pagename
 
end
 
end
 
 
 
function p.remove_the(frame)
 
function p.remove_the(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
return p.lua_remove_the(args[1])
+
return p.lua_remove_the(args[1])
 
end
 
end
   
   
  +
-- automatic standardization of comics names
--------------------------------------------------------------------------------------------------
 
-- normalización automática de los nombres de los cómics
 
 
function p.lua_standardized_comics_name(pagename)
 
function p.lua_standardized_comics_name(pagename)
local info = {}
+
local info = {}
local output = pagename
+
local output = pagename
  +
 
  +
if not h.isempty(pagename)
 
  +
if not h.isempty(pagename)
then
 
  +
then
info = p.lua_get_title_volume_issue(pagename, 'Vol')
 
  +
info = p.lua_get_title_volume_issue(pagename, 'Vol')
if not h.isempty(info.title)
 
  +
if not h.isempty(info.title)
then output = info.all
 
  +
then output = info.all
end
 
  +
end
end
 
  +
end
 
  +
return output
 
  +
return output
 
end
 
end
 
 
 
function p.standardized_comics_name(frame)
 
function p.standardized_comics_name(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
return p.lua_standardized_comics_name(args[1])
+
return p.lua_standardized_comics_name(args[1])
 
end
 
end
   
   
  +
-- automatic standardization of episodes names
--------------------------------------------------------------------------------------------------
 
-- normalización automática de los nombres de los episodios
 
 
function p.lua_standardized_episode_name(pagename)
 
function p.lua_standardized_episode_name(pagename)
local info = {}
+
local info = {}
local output = pagename
+
local output = pagename
   
if not h.isempty(pagename)
+
if not h.isempty(pagename)
then
+
then
info = p.lua_get_title_volume_issue(pagename, 'Season')
+
info = p.lua_get_title_volume_issue(pagename, 'Season')
if not h.isempty(info.title)
+
if not h.isempty(info.title)
then output = info.all
+
then output = info.all
  +
end
end
 
end
+
end
  +
 
return output
+
return output
 
end
 
end
 
 
 
function p.standardized_episode_name(frame)
 
function p.standardized_episode_name(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
return p.lua_standardized_episode_name(args[1])
+
return p.lua_standardized_comics_name(args[1])
 
end
 
end
   
--------------------------------------------------------------------------------------------------
 
-- devuelve el enlace tras la normalización de su nombre
 
function p.lua_standardized_link(pagename, pagetype, text)
 
local design = require("Module:Design")
 
local link = ''
 
local issue = ''
 
local info = {}
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
if string.find(pagename, '%]%].+') ~= nil
 
then return pagename
 
else pagename = h.break_link(pagename, 1)
 
end
 
if h.isempty(pagetype)
 
then pagetype = require("Module:PageType").get_page_type(pagename)
 
end
 
if not h.isempty(pagetype)
 
then
 
if pagetype == 'Comic' or pagetype == 'Volumen' or pagetype == 'Episodio'
 
then
 
if pagetype == 'Comic' or pagetype == 'Volumen'
 
then pagetype = 'Vol'
 
else pagetype = 'Temporada'
 
end
 
   
  +
-- returns link after standardization of its name
info = p.lua_get_title_volume_issue(pagename, pagetype)
 
  +
function p.lua_standardized_link(pagename, pagetype)
if not h.isempty(text)
 
  +
local design = require("Module:Design")
then output = h.Link(info.link.part1, text)
 
  +
local link = ''
else output = info.link.all
 
  +
local text = ''
end
 
  +
local issue = ''
elseif pagetype == 'Película' or pagetype == 'Videojuego' or pagetype == 'Series' or pagetype == 'Novela'
 
  +
local s1
then
 
  +
local s2
link = pagename
 
  +
local info = {}
text = string.gsub(pagename, ' %(.+%)', '')
 
  +
local output = ''
output = h.Link(link, design.span(text).italic)
 
  +
else output = h.Link(pagename)
 
  +
if not h.isempty(pagename)
end
 
  +
then
else output = h.Link(pagename)
 
  +
pagename = h.lua_breaklink(pagename, 1)
end
 
  +
if not h.isempty(pagetype)
end
 
  +
then
 
  +
if pagetype == 'Comics' or pagetype == 'Episode'
return output
 
  +
then
  +
if pagetype == 'Comics'
  +
then pagetype = 'Vol'
  +
else pagetype = 'Season'
  +
end
  +
  +
info = p.lua_get_title_volume_issue(pagename,pagetype)
  +
if not h.isempty(info.title)
  +
then
  +
if not h.isempty(info.issue)
  +
then
  +
link = info.noissue..' '..info.issue
  +
s1, s2 = string.match(info.issue, '(%d+): (.+)')
  +
if h.isempty(s2)
  +
then issue = ' #'..info.issue
  +
else issue = design.lua_span(': '..s2).italic
  +
end
  +
else
  +
link = info.noissue
  +
issue = ''
  +
end
  +
if info.volume == '1'
  +
then text = design.lua_span(info.title).italic .. issue
  +
else text = design.lua_span(info.noissue).italic .. issue
  +
end
  +
output = h.Link(link, text)
  +
end
  +
elseif pagetype == 'Film' or pagetype == 'Game'
  +
then
  +
link = pagename
  +
text = string.gsub(pagename, ' %(.+%)', '')
  +
output = h.Link(link, design.lua_span(text).italic)
  +
end
  +
else output = '[['..pagename..']]'
  +
end
  +
end
  +
  +
return output
 
end
 
end
   
 
--------------------------------------------------------------------------------------------------
 
 
--------------------------------------------------------------------------------------------------
 
 
function p.comics_link(frame)
 
function p.comics_link(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
  +
return p.lua_standardized_link(args[1], 'Comics')
local arg1 = args[1]
 
local output
 
 
if not h.isempty(arg1)
 
then
 
if h.in_list({'-', '--', '---', '—', '—'}, arg1)
 
then output = '—'
 
else output = p.lua_standardized_link(arg1, 'Comic', args[2])
 
end
 
end
 
 
return output
 
 
end
 
end
--------------------------------------------------------------------------------------------------
 
-- devuelve el nombre transformado en formato para la ordenación
 
---- elimina "El" del principio
 
---- para los cómics/episodios cambia el volumen/temporada y el número/episodio en números, en lugar de texto
 
function p.lua_standardized_name_for_sorting(pagename, pagetype)
 
local info = {}
 
local output = pagename
 
   
  +
function p.game_link(frame)
if not h.isempty(pagename) and not h.isempty(pagetype)
 
  +
local args = getArgs(frame)
then
 
  +
return p.lua_standardized_link(args[1], 'Game')
if pagetype == 'Comic' or pagetype == 'Episodio'
 
then
 
if pagetype == 'Comic'
 
then pagetype = 'Vol'
 
else pagetype = 'Temporada'
 
end
 
info = p.lua_get_title_volume_issue(pagename,pagetype)
 
if not h.isempty(info.title)
 
then output = info.sortname.all
 
end
 
elseif pagetype == 'Película' or pagetype == 'Videojuego' or pagetype == 'Novela'
 
then output = p.lua_remove_the(pagename)
 
end
 
end
 
 
return output
 
 
end
 
end
   
  +
function p.game_link_and_date(frame)
  +
local args = getArgs(frame)
  +
local page = args[1]
  +
local s_date = args[2]
  +
local output = ''
  +
  +
if not h.isempty(page)
  +
then
  +
if h.isempty(s_date)
  +
then s_date = h.lua_getFieldValue( h.lua_getContent(page), 'Release Date' )
  +
end
  +
  +
if not h.isempty(s_date)
  +
then s_date = '('..s_date..')'
  +
end
   
  +
output = p.lua_standardized_link(page, 'Game')..'<br />'..s_date
function p.comics_name_for_sorting(frame)
 
  +
end
local args = getArgs(frame)
 
  +
return p.lua_standardized_name_for_sorting(args[1], 'Comic')
 
  +
return output
 
end
 
end
   
   
  +
-- returns name transformed into format for sorting
--------------------------------------------------------------------------------------------------
 
  +
---- removes "The" from the begining
-- función para ordenar personajes, equipos, objetos, etc. por número de realidad
 
  +
---- for comics/episodes changes volume/season and issue/episode into numbers, instead of text
function p.name_for_sorting(frame)
 
  +
function p.lua_standardized_name_for_sorting(pagename,pagetype)
local args = getArgs(frame)
 
  +
local info = {}
local module_reality = require('Module:Realidad')
 
local output = p.lua_remove_the(args[1])
+
local output = ''
  +
 
  +
return module_reality.sort_by_reality({output})
 
  +
if not h.isempty(pagename) and not h.isempty(pagetype)
  +
then
  +
if pagetype == 'Comics' or pagetype == 'Episode'
  +
then
  +
if pagetype == 'Comics'
  +
then pagetype = 'Vol'
  +
else pagetype = 'Season'
  +
end
  +
info = p.lua_get_title_volume_issue(pagename,pagetype)
  +
if not h.isempty(info.title)
  +
then output = info.sortname.all
  +
end
  +
elseif pagetype == 'Film' or pagetype == 'Game'
  +
then output = p.lua_remove_the(pagename)
  +
end
  +
end
  +
  +
return output
  +
end
  +
function p.comics_name_for_sorting(frame)
  +
local args = getArgs(frame)
  +
return p.lua_standardized_name_for_sorting(args[1], 'Comics')
 
end
 
end
   
--------------------------------------------------------------------------------------------------
 
 
function p.lua_get_part(pagename,pagetype,part)
 
function p.lua_get_part(pagename,pagetype,part)
local output = ''
+
local output = ''
local info = {}
+
local info = {}
  +
 
if not h.isempty(pagename) and not h.isempty(pagetype)
+
if not h.isempty(pagename) and not h.isempty(pagetype)
then
+
then
if pagetype == 'Comic' or pagetype == 'Episodio'
+
if pagetype == 'Comics' or pagetype == 'Episode'
  +
then
then
 
if pagetype == 'Comic'
+
if pagetype == 'Comics'
then pagetype = 'Vol'
+
then pagetype = 'Vol'
else pagetype = 'Temporada'
+
else pagetype = 'Season'
  +
end
end
 
  +
 
info = p.lua_get_title_volume_issue(pagename,pagetype)
+
info = p.lua_get_title_volume_issue(pagename,pagetype)
if not h.isempty(title)
+
if not h.isempty(title)
  +
then
then
 
if part == 'Título'
+
if part == 'Title'
then output = info.title
+
then output = info.title
elseif part == 'Volumen'
+
elseif part == 'Volume'
then output = info.volume
+
then output = info.volume
elseif part == 'Cómic'
+
elseif part == 'Issue'
then output = info.issue
+
then output = info.issue
  +
end
end
 
  +
end
end
 
  +
end
end
 
end
+
end
  +
 
return output
+
return output
 
end
 
end
 
   
 
function p.get_part(frame)
 
function p.get_part(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
return p.lua_get_part(args[1], args[2], args[3])
+
return p.lua_get_part(args[1], args[2], args[3])
 
end
 
end
 
   
 
function p.get_title_and_volume(frame)
 
function p.get_title_and_volume(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
local pagename = args[1]
+
local pagename = args[1]
local info = {}
+
local info = {}
local output = ''
+
local output = ''
  +
 
if not h.isempty(pagename)
+
if not h.isempty(pagename)
then
+
then
info = p.lua_get_title_volume_issue(pagename, 'Vol')
+
info = p.lua_get_title_volume_issue(pagename, 'Vol')
output = info.title .. ' Vol ' .. info.volume
+
output = info.title .. ' Vol ' .. info.volume
end
+
end
  +
 
return output
+
return output
 
end
 
end
   
   
--------------------------------------------------------------------------------------------------
 
 
function p.lua_cid(pagename)
 
function p.lua_cid(pagename)
local m_date = require("Module:Date")
+
local m_date = require("Module:Date")
local design = require("Module:Design")
+
local design = require("Module:Design")
  +
--local module_page_type = require("Module:PageType")
local release_date = ''
 
local month = ''
+
local release_date = ''
local year = ''
+
local month = ''
local page_content = ''
+
local year = ''
local info
+
--local page_type = ''
local link
+
local page_content = ''
  +
local info
local div = mw.html.create( 'div' ):attr( 'align', 'center' ):done()
 
  +
local link
local output = ''
 
  +
local div = mw.html.create( 'div' ):attr( 'align', 'center' ):done()
 
  +
local output = ''
if not h.isempty(pagename)
 
  +
then
 
output = p.lua_standardized_link(pagename, 'Comic')
+
if not h.isempty(pagename)
  +
then
output = design.span(output).bold
 
  +
--page_type = module_page_type.lua_getPageType(pagename)
page_content = h.get_content(p.lua_get_title_volume_issue(pagename, 'Vol').all)
 
  +
--if page_type == 'Comic'
release_date = h.get_field_value(page_content, 'Lanzado')
 
  +
--then
if not h.isempty(release_date)
 
  +
--pagename = p.lua_get_title_volume_issue(pagename, 'Vol').all
then
 
  +
output = p.lua_standardized_link(pagename, 'Comics')
info = m_date.lua_get_release_date_info(release_date)
 
  +
output = design.lua_span(output).bold
link = h.Link(info.week.text, info.no_day)
 
  +
page_content = h.lua_getContent(pagename)
else
 
month = h.get_field_value(page_content, 'Mes')
+
release_date = h.lua_getFieldValue(page_content, 'ReleaseDate')
year = h.get_field_value(page_content, 'Año')
 
info = m_date.lua_get_publication_date_info(year, month, false)
 
link = string.gsub(info.link, '%]%], %[%[:Category:%d+|', ', ')
 
end
 
   
if not h.isempty(link)
+
if not h.isempty(release_date)
  +
then
then output = output..'<br>('..link..')'
 
  +
info = m_date.lua_get_release_date_info(release_date)
end
 
  +
link = h.lua_link_to_category( info.week.text, info.no_day )
 
  +
else
output = tostring( div:wikitext(output) )
 
  +
month = h.lua_getFieldValue(page_content, 'Month')
end
 
  +
year = h.lua_getFieldValue(page_content, 'Year')
 
  +
info = m_date.lua_get_publication_date_info(year, month, false)
return output
 
  +
link = string.gsub(info.link, '%]%], %[%[:Category:%d+|', ', ')
  +
end
  +
  +
if not h.isempty(link)
  +
then output = output..'<br>('..link..')'
  +
end
  +
  +
output = tostring( div:wikitext(output) )
  +
end
  +
  +
return output
 
end
 
end
   
   
 
function p.cid(frame)
 
function p.cid(frame)
local args = getArgs(frame)
+
local args = getArgs(frame)
return p.lua_cid(args[1])
+
return p.lua_cid(args[1])
 
end
 
end
   
--------------------------------------------------------------------------------------------------
 
-- sustituye "#" por "Vol" o "Temporada"
 
function p.lua_replace_number_sign(pagename, pagetype)
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
if h.isempty(pagetype)
 
then pagetype = ''
 
end
 
 
if string.find(pagename, '#') ~= nil
 
then
 
if string.find(pagename, ' Vol ') ~= nil or string.find(pagename, ' Temporada ') ~= nil
 
then output = string.gsub(pagename, '#', '')
 
elseif pagetype == 'Comic' or h.exists( string.gsub(pagename, '#', 'Vol 1 ') )
 
then output = string.gsub(pagename, '#', 'Vol 1 ')
 
elseif pagetype == 'Episodio' or h.exists( string.gsub(pagename, '#', 'Temporada 1 ') )
 
then output = string.gsub(pagename, '#', 'Temporada 1 ')
 
end
 
else
 
output = pagename
 
end
 
end
 
 
return output
 
end
 
 
--------------------------------------------------------------------------------------------------
 
function p.lua_get_release_date(pagename, pagetype)
 
local m_date = require("Module:Date")
 
local page_content = ''
 
local release_date = ''
 
local year = ''
 
local month = ''
 
local day = ''
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
if h.isempty(pagetype)
 
then pagetype = require("Module:PageType").get_page_type(pagename)
 
end
 
page_content = h.get_content(pagename)
 
if page_content ~= ''
 
then
 
if pagetype == 'Comic'
 
then
 
release_date = h.get_field_value(page_content, 'Lanzado')
 
if not h.isempty(release_date)
 
then
 
info = m_date.lua_get_release_date_info(release_date)
 
output = h.Link(info.week.text, info.no_day)
 
else
 
month = h.get_field_value(page_content, 'Mes')
 
year = h.get_field_value(page_content, 'Año')
 
info = m_date.lua_get_publication_date_info(year, month, false)
 
output = string.gsub(info.link, '%]%], %[%[:Category:%d+|', ', ')
 
end
 
elseif pagetype == 'Episodio'
 
then
 
year = h.get_field_value(page_content, 'Año')
 
month = h.get_field_value(page_content, 'Mes')
 
day = h.get_field_value(page_content, 'Día')
 
if not h.isempty(year) and not h.isempty(month) and not h.isempty(day)
 
then
 
month = m_date.get_month_name({month})
 
output = h.LinkToCategory(year..', '..month, month..' '..day..', '..year)
 
end
 
elseif pagetype == 'Película' or pagetype == 'Videojuego' or pagetype == 'Novela'
 
then output = h.get_field_value(page_content, 'Release Date')
 
end
 
end
 
end
 
 
return output
 
end
 
 
 
--------------------------------------------------------------------------------------------------
 
function p.lua_get_link_and_release_date(pagename, pagetype, text, release_date)
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
if h.isempty(pagetype)
 
then pagetype = require("Module:PageType").get_page_type(pagename)
 
end
 
output = p.lua_standardized_link(pagename, pagetype, text)
 
if h.isempty(release_date)
 
then release_date = p.lua_get_release_date(pagename, pagetype)
 
end
 
if not h.isempty(release_date)
 
then output = output..'<br>('..release_date..')'
 
end
 
 
output = output..'<br>'
 
end
 
 
return output, release_date
 
end
 
 
--------------------------------------------------------------------------------------------------
 
-- utilizado en Plantilla:Sl
 
function p.get_link(frame)
 
local args = getArgs(frame)
 
local pagename = args[1]
 
local text = args[2]
 
local pagetype = args['type']
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
if h.isempty(pagetype)
 
then pagetype = require("Module:PageType").get_page_type(pagename)
 
end
 
output = p.lua_standardized_link(pagename, pagetype, text)
 
end
 
 
return output
 
end
 
 
 
--------------------------------------------------------------------------------------------------
 
-- utilizado en Plantilla:Sld
 
function p.get_link_and_release_date(frame)
 
local args = getArgs(frame)
 
local pagename = args[1]
 
local text = args[2]
 
local pagetype = args['tipo']
 
local release_date = args['fecha']
 
 
local output = p.lua_get_link_and_release_date(pagename, pagetype, text, release_date)
 
 
return output
 
end
 
 
 
--------------------------------------------------------------------------------------------------
 
-- devuelve el enlace al episodio, pero sustituye el texto por el título del episodio
 
-- utilizado en la plantilla:Elt
 
function p.get_link_to_episode_with_title(frame)
 
local args = getArgs(frame)
 
local pagename = args[1]
 
local text
 
local pagetype = 'Episodio'
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
text = p.lue_get_episode_title(pagename)
 
if text == pagename
 
then output = p.lua_standardized_link(pagename, pagetype)
 
else output = p.lua_standardized_link(pagename, pagetype, text)
 
end
 
end
 
 
return output
 
end
 
 
 
--------------------------------------------------------------------------------------------------
 
-- utilizado en Plantilla:Eltd
 
function p.get_link_and_release_date_to_episode_with_title(frame)
 
local args = getArgs(frame)
 
local pagename = args[1]
 
local text
 
local release_date = args['Fecha']
 
local pagetype = 'Episodio'
 
local output = ''
 
 
if not h.isempty(pagename)
 
then
 
pagename = p.lua_replace_number_sign(pagename, pagetype)
 
text = p.lue_get_episode_title(pagename)
 
if text == pagename
 
then output = p.lua_standardized_link(pagename, pagetype)
 
else output = p.lua_standardized_link(pagename, pagetype, text)
 
end
 
if h.isempty(release_date)
 
then release_date = p.lua_get_release_date(pagename, pagetype)
 
end
 
if not h.isempty(release_date)
 
then output = output..'<br>('..release_date..')'
 
end
 
end
 
 
return output
 
end
 
   
  +
--[[
--------------------------------------------------------------------------------------------------
 
function p.lue_get_episode_title(pagename)
+
function p.lua_releasedate()--pagename,pagetype)
local page_content = ''
+
local s = ''
local output = ''
+
local releasedate = ''
  +
local year = ''
 
  +
local month = ''
if not h.isempty(pagename)
 
  +
local day = ''
then
 
  +
local pagename = 'Legion (TV series) Season 1 1'
pagename = p.lua_replace_number_sign(pagename, 'Episodio')
 
  +
--local pagename = 'FF Vol 1 1'
page_content = h.get_content(pagename)
 
  +
--local pagename = 'X-Men: Mutant Academy'
if page_content ~= ''
 
  +
--local pagename = 'Captain Marvel (film)'
then output = h.get_field_value(page_content, 'Título')
 
  +
local pagetype = 'Episode'
end
 
  +
--local pagetype = 'Comics'
 
  +
--local pagetype = 'Game'
if output ~= ''
 
  +
--local pagetype = 'Film'
then output = '"'..output..'"'
 
  +
else output = pagename
 
  +
if not h.isempty(pagename) and not h.isempty(pagetype)
end
 
  +
then
end
 
  +
s = mw.title.new(pagename):getContent()
 
  +
if not h.isempty(s)
return output
 
  +
then
  +
if pagetype == 'Comics'
  +
then
  +
year = string.match(s, "|%s+Year%s+=%s+(.-)\n")
  +
month = string.match(s, "|%s+Month%s+=%s+(.-)\n")
  +
if not h.isempty(year) and not h.isempty(month)
  +
then releasedate = month..', '..year
  +
end
  +
elseif pagetype == 'Episode'
  +
then
  +
year = string.match(s, "|%s+Year%s+=%s+(.-)\n")
  +
month = string.match(s, "|%s+Month%s+=%s+(.-)\n")
  +
day = string.match(s, "|%s+Day%s+=%s+(.-)\n")
  +
if not h.isempty(year) and not h.isempty(month) and not h.isempty(day)
  +
then releasedate = day..' '..month..', '..year
  +
end
  +
elseif pagetype == 'Film' or pagetype == 'Game'
  +
then releasedate = string.match(s, "|%s+Release Date%s+=%s+(.-)\n")
  +
end
  +
end
  +
end
  +
  +
return releasedate
 
end
 
end
  +
]]--
   
 
return p
 
return p

Revisión del 19:38 2 nov 2021

La documentación para este módulo puede ser creada en Módulo:StandardizedName/doc

local p = {}
local h = require("Module:HF")
local getArgs = require('Dev:Arguments').getArgs
---- //*** Functions for transforming pagenames of comics/episodes into desirable format ***// ----


-- returns transformed issue/episode number that can be used for sorting in categories as numbers, instead of text, including "point one" issues and "-1"/"negative" issues
function p.lua_padded_issue(issue)
    local minus = '5'
    local point_one = '00'
    local i = ''
    local j = ''
    local output = ''
    local s1 = ''
    local s2 = ''
    
    if not h.isempty(issue)
        then
            if issue == '½'
                then issue = '0.5'
            end
            
            s1, s2 = string.match( string.lower(issue), '(%d+)(%l)')--'(%d+)(%D+)')
            if not h.isempty( s2 ) --and s2 ~= '.'
                then issue = s1..'.'..s2
            end
            
            if string.match(issue, '^%-*%d', 1) ~= nil --check if issue starts with number (including negative numbers like -1)
                then
                    -- -1 issues
                    j = string.find(issue,"-",1,true)
                    if not h.isempty(j)
                        then
                            i = string.sub(issue,2,#issue)
                            j = string.find(i,".",1,true)
                            if not h.isempty(j) 
                                then minus = 5 - #string.sub(i,1,j-1)
                                else minus = 5 - #i
                            end
                        else
                            i = issue
                    end
    
                    -- point one issues
                    j = string.find(i,".",1,true) 
                    if not h.isempty(j)
                        then
                            point_one = string.sub(i,j+1,#i)
                            if tonumber(point_one) == nil
                                then point_one = '99' -- for issues with letters after . instead of just numbers (for example, Amazing Spider-Man Vol 5 #16.HU)
                            end
                            point_one = string.rep("0", 2-#point_one)..point_one
                            i = string.sub(i,1,j-1)
                    end
    
                    output = minus..string.rep("0", 6-#i)..i..point_one
                else -- issue is not a number
                    output = issue --'999999999'
            end
    end
    
    return output
end

-- returns transformed volume/season number that can be used for sorting in categories as numbers, instead of text
function p.lua_padded_volume(volume)
    local output = ''
    
    if not h.isempty(volume)
        then output = string.rep("0", 6-#volume)..volume
    end
    
    return output
end

-- returns transformed title, with replaced characters like ":" or "/" that can be used for names of files (for example, covers)
function p.lua_title_for_files(title)
    local output = title
    
    output = string.gsub(output,'/',' ')
    output = string.gsub(output,':','')
    output = string.gsub(output,'&#38;','&')
    output = string.gsub(output,'&#39;',"'") 

    return output
end

-- break down pagename of comics/episodes into parts - title, volume/season, issue/episode. 
---- Also returns transformed volume/season number and issue/episode number that can be used for sorting in categories as numbers, instead of text, including "point one" issues and "-1"/"negative" issues
---- Also returns transformed title, with replaced characters like ":" or "/" that can be used for names of files (for example, covers)
function p.lua_get_title_volume_issue(pagename, pagetype)
    local title = ''
    local volume = ''
    local issue = ''
    local padded_issue = ''
    local padded_volume = ''
    local title_for_files = ''
    local remainder_issue = ''
    local clean_issue = ''
    local j
    local k
    
    if h.isempty(pagetype)
        then pagetype = 'Vol'
    end
    
    j,k = string.find(pagename, ' '..pagetype..' %d+ ')
    if not h.isempty(j)
        then
            title = string.sub(pagename, 1, j-1)
            issue = string.gsub(string.sub(pagename, k+1, #pagename), '#', '')
            j,k,volume = string.find(pagename, ' '..pagetype..' (%d+) ')
        else
            j,k = string.find(pagename, ' #')
            if h.isempty(j)
                then
                    j,k = string.find(pagename, ' '..pagetype..' %d+')
                    if not h.isempty(j)
                        then
                            title = string.sub(pagename, 1, j-1)
                            volume = string.sub(pagename, j+#pagetype+2, k)
                        else return ''
                    end
                else
                    title = string.sub(pagename, 1, j-1)
                    issue = string.sub(pagename, k+1, #pagename)
                    volume = '1'
            end
    end
    
    if not h.isempty(issue) and tonumber(issue) == nil
        then clean_issue, remainder_issue = string.match(issue, '(%d+)(%D+)')
    end

    padded_volume = p.lua_padded_volume(volume)
    padded_issue = p.lua_padded_issue(issue)
    title_for_files = p.lua_title_for_files(title)
    return {  ['title'] = title, 
              ['volume'] = volume,
              ['issue'] = issue,
              ['clean_issue'] = clean_issue or '',
              ['remainder_issue'] = remainder_issue or '',
              ['padded_volume'] = padded_volume,
              ['padded_issue'] = padded_issue,
              ['title_for_files'] = title_for_files,
              ['filename'] = {
                  ['title'] = title_for_files,
                  ['noissue'] = title_for_files..' '..pagetype..' '..volume,
                  ['all'] = title_for_files..' '..pagetype..' '..volume..' '..issue,
              },
              ['sortname'] = {
                  ['title'] = p.lua_remove_the(title),
                  ['noissue'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume,
                  ['all'] = p.lua_remove_the(title)..' '..pagetype..' '..padded_volume..' '.. padded_issue,
              },
              ['noissue'] = title..' '..pagetype..' '..volume,
              ['all'] = title..' '..pagetype..' '..volume..' '..issue,
           }
end


-- removes "The " from the start of pagename
function p.lua_remove_the(pagename)
    if not h.isempty(pagename) and string.lower( string.sub(pagename, 1, 4) ) == 'the '
        then pagename = string.sub(pagename, 5, #pagename)
    end
    return pagename
end
function p.remove_the(frame)
    local args = getArgs(frame)
    return p.lua_remove_the(args[1])
end


-- automatic standardization of comics names
function p.lua_standardized_comics_name(pagename)
    local info = {}
    local output = pagename
    
    
    if not h.isempty(pagename)
        then 
            info = p.lua_get_title_volume_issue(pagename, 'Vol')
            if not h.isempty(info.title)
                then output = info.all
            end
    end
    
    return output
end
function p.standardized_comics_name(frame)
    local args = getArgs(frame)
    return p.lua_standardized_comics_name(args[1])
end


-- automatic standardization of episodes names
function p.lua_standardized_episode_name(pagename)
    local info = {}
    local output = pagename

    if not h.isempty(pagename)
        then 
            info = p.lua_get_title_volume_issue(pagename, 'Season')
            if not h.isempty(info.title)
                then output = info.all
            end
    end
    
    return output
end
function p.standardized_episode_name(frame)
    local args = getArgs(frame)
    return p.lua_standardized_comics_name(args[1])
end


-- returns link after standardization of its name
function p.lua_standardized_link(pagename, pagetype)
    local design = require("Module:Design")
    local link = ''
    local text = ''
    local issue = ''
    local s1
    local s2
    local info = {}
    local output = ''
    
    if not h.isempty(pagename)
        then
            pagename = h.lua_breaklink(pagename, 1)
            if not h.isempty(pagetype)
                then
                    if pagetype == 'Comics' or pagetype == 'Episode'
                        then
                            if pagetype == 'Comics'
                                then pagetype = 'Vol'
                                else pagetype = 'Season'
                            end
    
                            info = p.lua_get_title_volume_issue(pagename,pagetype)
                            if not h.isempty(info.title)
                                then
                                    if not h.isempty(info.issue)
                                        then 
                                            link = info.noissue..' '..info.issue
                                            s1, s2 = string.match(info.issue, '(%d+): (.+)')
                                            if h.isempty(s2)
                                                then issue = ' #'..info.issue
                                                else issue = design.lua_span(': '..s2).italic
                                            end
                                        else
                                            link = info.noissue
                                            issue = ''
                                    end
                                    if info.volume == '1'
                                        then text = design.lua_span(info.title).italic .. issue
                                        else text = design.lua_span(info.noissue).italic .. issue
                                    end
                                    output = h.Link(link, text)
                            end
                        elseif pagetype == 'Film' or pagetype == 'Game'
                            then
                                link = pagename
                                text = string.gsub(pagename, ' %(.+%)', '')
                                output = h.Link(link, design.lua_span(text).italic)
                    end
                else output = '[['..pagename..']]'
            end
    end
    
    return output
end

function p.comics_link(frame)
    local args = getArgs(frame)
    return p.lua_standardized_link(args[1], 'Comics')
end

function p.game_link(frame)
    local args = getArgs(frame)
    return p.lua_standardized_link(args[1], 'Game')
end

function p.game_link_and_date(frame)
    local args = getArgs(frame)
    local page = args[1]
    local s_date = args[2]
    local output = ''
    
    if not h.isempty(page)
        then
            if h.isempty(s_date)
                then s_date = h.lua_getFieldValue( h.lua_getContent(page), 'Release Date' )
            end
            
            if not h.isempty(s_date)
                then s_date = '('..s_date..')'
            end

            output = p.lua_standardized_link(page, 'Game')..'<br />'..s_date
    end
    
    return output
end


-- returns name transformed into format for sorting 
---- removes "The" from the begining
---- for comics/episodes changes volume/season and issue/episode into numbers, instead of text
function p.lua_standardized_name_for_sorting(pagename,pagetype)
    local info = {}
    local output = ''
    
    
    if not h.isempty(pagename) and not h.isempty(pagetype)
        then
            if pagetype == 'Comics' or pagetype == 'Episode'
                then
                    if pagetype == 'Comics'
                        then pagetype = 'Vol'
                        else pagetype = 'Season'
                    end
                    info = p.lua_get_title_volume_issue(pagename,pagetype)
                    if not h.isempty(info.title)
                        then output = info.sortname.all
                    end
                elseif pagetype == 'Film' or pagetype == 'Game'
                    then output = p.lua_remove_the(pagename)
            end
    end
    
    return output
end
function p.comics_name_for_sorting(frame)
    local args = getArgs(frame)
    return p.lua_standardized_name_for_sorting(args[1], 'Comics')
end

function p.lua_get_part(pagename,pagetype,part)
    local output = ''
    local info = {}
    
    if not h.isempty(pagename) and not h.isempty(pagetype)
        then 
            if pagetype == 'Comics' or pagetype == 'Episode'
                then
                    if pagetype == 'Comics'
                        then pagetype = 'Vol'
                        else pagetype = 'Season'
                    end
                    
                    info = p.lua_get_title_volume_issue(pagename,pagetype)
                    if not h.isempty(title)
                        then 
                            if part == 'Title'
                                then output = info.title
                                elseif part == 'Volume'
                                    then output = info.volume
                                    elseif part == 'Issue'
                                        then output = info.issue
                            end
                    end
            end
    end
    
    return output
end

function p.get_part(frame)
    local args = getArgs(frame)
    return p.lua_get_part(args[1], args[2], args[3])
end

function p.get_title_and_volume(frame)
    local args = getArgs(frame)
    local pagename = args[1]
    local info = {}
    local output = ''
    
    if not h.isempty(pagename)
        then 
            info = p.lua_get_title_volume_issue(pagename, 'Vol')
            output = info.title .. ' Vol ' .. info.volume
    end
    
    return output
end


function p.lua_cid(pagename)
    local m_date = require("Module:Date")
    local design = require("Module:Design")
    --local module_page_type = require("Module:PageType")
    local release_date = ''
    local month = ''
    local year = ''
    --local page_type = ''
    local page_content = ''
    local info
    local link
    local div = mw.html.create( 'div' ):attr( 'align', 'center' ):done()
    local output = ''
    
    if not h.isempty(pagename)
        then
            --page_type = module_page_type.lua_getPageType(pagename)
            --if page_type == 'Comic'
                --then
                    --pagename = p.lua_get_title_volume_issue(pagename, 'Vol').all
            output = p.lua_standardized_link(pagename, 'Comics')
            output = design.lua_span(output).bold
            page_content = h.lua_getContent(pagename)
            release_date = h.lua_getFieldValue(page_content, 'ReleaseDate')

            if not h.isempty(release_date)
                then
                    info = m_date.lua_get_release_date_info(release_date)
                    link = h.lua_link_to_category( info.week.text, info.no_day )
                else
                    month = h.lua_getFieldValue(page_content, 'Month')
                    year = h.lua_getFieldValue(page_content, 'Year')
                    info = m_date.lua_get_publication_date_info(year, month, false)
                    link = string.gsub(info.link, '%]%], %[%[:Category:%d+|', ', ')
            end
            
            if not h.isempty(link)
                then output = output..'<br>('..link..')'
            end
            
            output = tostring( div:wikitext(output) )
    end
    
    return output
end


function p.cid(frame)
    local args = getArgs(frame)
    return p.lua_cid(args[1])
end


--[[
function p.lua_releasedate()--pagename,pagetype)
    local s = ''
    local releasedate = ''
    local year = ''
    local month = ''
    local day = ''
    local pagename = 'Legion (TV series) Season 1 1'
    --local pagename = 'FF Vol 1 1'
    --local pagename = 'X-Men: Mutant Academy'
    --local pagename = 'Captain Marvel (film)'
    local pagetype = 'Episode'
    --local pagetype = 'Comics'
    --local pagetype = 'Game'
    --local pagetype = 'Film'
 
    if not h.isempty(pagename) and not h.isempty(pagetype)
        then
            s = mw.title.new(pagename):getContent()
            if not h.isempty(s)
                then 
                    if pagetype == 'Comics'
                        then
                            year = string.match(s, "|%s+Year%s+=%s+(.-)\n")
                            month = string.match(s, "|%s+Month%s+=%s+(.-)\n")
                            if not h.isempty(year) and not h.isempty(month)
                                then releasedate = month..', '..year
                            end
                        elseif pagetype == 'Episode'
                            then 
                                year = string.match(s, "|%s+Year%s+=%s+(.-)\n")
                                month = string.match(s, "|%s+Month%s+=%s+(.-)\n")
                                day = string.match(s, "|%s+Day%s+=%s+(.-)\n")
                                if not h.isempty(year) and not h.isempty(month) and not h.isempty(day)
                                    then releasedate = day..' '..month..', '..year
                                end
                            elseif pagetype == 'Film' or pagetype == 'Game'
                                then releasedate = string.match(s, "|%s+Release Date%s+=%s+(.-)\n")
                    end
            end
    end
    
    return releasedate
end
]]--

return p