« Module:Weblink » : différence entre les versions
Aller à la navigation
Aller à la recherche
ce |
mAucun résumé des modifications |
||
| Ligne 7 : | Ligne 7 : | ||
if not showntext then | if not showntext then | ||
showntext = string.gsub( url, 'https?://', '') | showntext = string.gsub( url, 'https?://', '') | ||
end | |||
if string.sub(showntext, #showntext, #showntext) then -- remove trailing slash | |||
showntext = string.sub(showntext, 1, #showntext - 1) | |||
end | end | ||
return '[' .. url .. ' ' .. showntext .. ']' | return '[' .. url .. ' ' .. showntext .. ']' | ||
Version du 16 janvier 2015 à 09:16
local p = {}
function p.makelink(url, showntext) if not url then return nil end if not showntext then showntext = string.gsub( url, 'https?://', ) end if string.sub(showntext, #showntext, #showntext) then -- remove trailing slash showntext = string.sub(showntext, 1, #showntext - 1) 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