« Module:Weblink » : différence entre les versions

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche
0x010D (discussion | contributions)
Aucun résumé des modifications
0x010D (discussion | contributions)
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


local w = require "Module:Wikidata"
function p.makelink(url, showntext)
local frame = mw.getCurrentFrame()
if not url then
 
return nil
function p.makelink(astring)
end
return '[' .. astring ..  ' ' ..  frame:callParserFunction( '#titleparts', { astring, '', 3 } ) .. ']'
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(strinlist) == table then return nil end
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] = prettylink(stringlist[j])
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