Open main menu

Changes

Module:Authority control

603 bytes added, 08:24, 6 April 2013
m
no edit summary
function lccnLink( id )
cleanedId = ''
if string.match( id, '^%l%l?%l?/%d%d%d?%d?/%d%d%d%d%d%d+$' ) then cleanedId local parts = string.gsubsplit( id, '(%l+)/(%d+' )/ cleanedId = parts[1] .. parts[2] .. append(%d+)$' parts[3], '%1%2%30' , 6 )
elseif string.match( id, '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
cleanedId = id
end
return '[http://id.loc.gov/authorities/names/' .. cleanedId .. ' ' .. cleanedId .. ']'
end
 
--Do split before deployment of mw.text.split
function split( str, c )
local parts = {}
local current = ''
local length = string.len( str )
for i = 1,length do
local ch = string.char( string.byte( str, i ) )
if ch == c then
table.insert( parts, current )
current = ''
else
current = current .. ch
end
end
table.insert( parts, current )
return parts
end
 
function append(str, c, length)
while string.len( str ) < length do
str = c .. str
end
return str
end
Anonymous user