« Module:Weblink » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function p.makelink(url, showntext) | |||
if not url then | |||
return nil | |||
end | |||
return '[' .. | if not showntext then | ||
showntext = string.gsub( url, {'http://', 'https://'}, '') | |||
end | |||
return '[' .. url .. ' ' .. showntext .. ']' | |||
end | end | ||
function p.makelinks(stringlist) | function p.makelinks(stringlist, separator) | ||
if not type( | if not type(stringlist) == table then | ||
return error('stringlist should be table') | |||
end | |||
if not separator then | |||
separator = '<br />' | |||
end | |||
for i, j in pairs(stringlist) do | for i, j in pairs(stringlist) do | ||
stringlist[i] = | stringlist[i] = p.makelink(k) | ||
return stringlist | return table.concat(stringlist, separator ) | ||
end | end | ||
end | end | ||
return p | return p | ||
Version du 1 octobre 2014 à 15:22
local p = {}
function p.makelink(url, showntext) if not url then return nil end if not showntext then showntext = string.gsub( url, {'http://', 'https://'}, ) end return '[' .. url .. ' ' .. showntext .. ']' end
function p.makelinks(stringlist, separator)
if not type(stringlist) == table then
return error('stringlist should be table')
end
if not separator then
separator = '
'
end
for i, j in pairs(stringlist) do
stringlist[i] = p.makelink(k)
return table.concat(stringlist, separator )
end
end
return p