This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
This module implements template {{Link string}}.
Usage[Quelltext bearbeiten]
{{#invoke:Link string|main}}
local ls = {}
function ls.main(frame)
local r = nil
local args = frame:getParent().args
if args[1] and #args[1]>0 then
r = mw.text.trim(args[1])
while mw.ustring.sub( r, 2, 2 ) ~= '[' do
r = '[' .. r
end
while mw.ustring.sub( r, -2, -2 ) ~= ']' do
r = r .. ']'
end
end
return r
end
function ls.unlink(frame)
local r = nil
local args = frame:getParent().args
if args[1] and #args[1]>0 then
r = mw.text.trim(args[1])
while mw.ustring.sub( r, 1, 1 ) == '[' do
r = mw.ustring.sub( r, 2 )
end
while mw.ustring.sub( r, -1 ) == ']' do
r = mw.ustring.sub( r, 1, -2 )
end
end
return r
end
return ls