Modul:WLink: Unterschied zwischen den Versionen
2018-09-23 Special:Diff/181178730/next
w>Mabschaaf (akt. gem. Special:Diff/181153700/next) |
w>XenonX3 (2018-09-23 Special:Diff/181178730/next) |
||
| Zeile 1: | Zeile 1: | ||
local WLink = { suite = "WLink", | local WLink = { suite = "WLink", | ||
serial = "2018-09- | serial = "2018-09-23", | ||
item = 19363224 }; | item = 19363224 }; | ||
--[=[ | --[=[ | ||
| Zeile 21: | Zeile 21: | ||
getTitle() | getTitle() | ||
getWeblink() | getWeblink() | ||
getWikilink() | |||
isBracketedLink() | isBracketedLink() | ||
isBracketedURL() | isBracketedURL() | ||
| Zeile 455: | Zeile 456: | ||
-- Postcondition: | -- Postcondition: | ||
-- Returns string, with suitable link title | -- Returns string, with suitable link title | ||
return | local s = mw.text.trim( attempt ); | ||
return s:gsub( "\n", " " ) | |||
:gsub( "%[", "[" ) | |||
:gsub( "%]", "]" ) | |||
:gsub( "|", "|" ); | |||
end -- WLink.getEscapedTitle() | end -- WLink.getEscapedTitle() | ||
| Zeile 911: | Zeile 913: | ||
return r; | return r; | ||
end -- WLink.getWeblink() | end -- WLink.getWeblink() | ||
function WLink.getWikilink( attempt, appear ) | |||
-- Retrieve bracketed link from text | |||
-- Precondition: | |||
-- attempt -- string, with current target, or plain | |||
-- appear -- string, with link title, or nil | |||
-- Postcondition: | |||
-- Returns string, with first detected link target | |||
-- false if nothing found | |||
local r = WLink.pageTarget( attempt ); | |||
if r then | |||
if appear then | |||
local show = WLink.getEscapedTitle( appear ); | |||
if show ~= r and show ~= "" then | |||
r = string.format( "%s|%s", r, show ); | |||
end | |||
end | |||
r = string.format( "[[%s]]", r ); | |||
end | |||
return r; | |||
end -- WLink.getWikilink() | |||
| Zeile 1.336: | Zeile 1.361: | ||
s = mw.text.trim( v ); | s = mw.text.trim( v ); | ||
end | end | ||
elseif ( k == 2 | elseif ( k == 2 and | ||
( action == "getNamespaced" or | |||
action == "getWikilink" ) ) or | |||
( k == "space" and action == "ansiPercent" ) then | ( k == "space" and action == "ansiPercent" ) then | ||
if v ~= "" then | if v ~= "" then | ||
| Zeile 1.436: | Zeile 1.463: | ||
p.getWeblink = function ( frame ) | p.getWeblink = function ( frame ) | ||
return Template( frame, "getWeblink" ); | return Template( frame, "getWeblink" ); | ||
end | |||
p.getWikilink = function ( frame ) | |||
return Template( frame, "getWikilink" ); | |||
end | end | ||
p.isBracketedLink = function ( frame ) | p.isBracketedLink = function ( frame ) | ||
| Zeile 1.472: | Zeile 1.502: | ||
p.isWikilink = function ( frame ) | p.isWikilink = function ( frame ) | ||
return Template( frame, "isWikilink" ); | return Template( frame, "isWikilink" ); | ||
end | end | ||
p.failsafe = function ( frame ) | p.failsafe = function ( frame ) | ||