Modul:WLink: Unterschied zwischen den Versionen

K
35 Versionen von wikivoyage:Modul:WLink importiert
w>Schniggendiller
(c/p aus https://de.wikipedia.beta.wmflabs.org/w/index.php?oldid=19757 (Spezial:PermaLink/163959359#Einmal geschütztes Modul aktualisieren))
K (35 Versionen von wikivoyage:Modul:WLink importiert)
 
(20 dazwischenliegende Versionen von 13 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local WLink = { suite  = "WLink",
local WLink = { suite  = "WLink",
                 serial = "2017-01-25" };
                 serial = "2016-10-05" };
--[=[
--[=[
ansiPercent()
ansiPercent()
Zeile 6: Zeile 6:
getArticleBase()
getArticleBase()
getBaseTitle()
getBaseTitle()
getEscapedTitle()
getExtension()
getExtension()
getFile()
getFile()
Zeile 332: Zeile 333:
         end
         end
     end -- for --i
     end -- for --i
    r = mw.ustring.gsub(r, '^%*', '%%2A')
     return r;
     return r;
end -- WLink.ansiPercent()
end -- WLink.ansiPercent()
Zeile 435: Zeile 437:
end -- WLink.getBaseTitle()
end -- WLink.getBaseTitle()


 
function WLink.getEscapedTitle( attempt )
    -- Retrieve escaped link title
    -- Precondition:
    --    attempt  -- string, with presumable link title
    -- Postcondition:
    --    Returns  string, with suitable link title
    local s = mw.text.trim( attempt );
    return s:gsub( "\n", " " )
            :gsub( "%[", "[" )
            :gsub( "%]", "]" )
            :gsub( "|",  "|" );
end -- WLink.getEscapedTitle()


function WLink.getExtension( attempt )
function WLink.getExtension( attempt )
Zeile 590: Zeile 603:
     local r = attempt;
     local r = attempt;
     local i = 1;
     local i = 1;
     local j, k, n, lean, s, shift, span, space, suffix;
     local j, k, n, lean, s, shift, space, suffix;
     while ( true ) do
     while ( true ) do
         j = r:find( "[", i, true );
         j = r:find( "[", i, true );
Zeile 629: Zeile 642:
                     end
                     end
                 else
                 else
                     span, shift = extractExtlink( suffix );
                     s, shift = extractExtlink( suffix );
                     if span then
                     if not s then
                         if not shift then
                         s = "";
                            shift = "";
                    end
                        end
                     if not shift then
                     else
                         shift = "";
                         shift = string.format( "[%s]", s );
                     end
                     end
                     i = i - 1;
                     i = i - 1;
Zeile 1.179: Zeile 1.191:
p.getBaseTitle = function ( frame )
p.getBaseTitle = function ( frame )
     return Template( frame, "getBaseTitle" );
     return Template( frame, "getBaseTitle" );
end
p.getEscapedTitle = function ( frame )
    return Template( frame, "getEscapedTitle" );
end
end
p.getExtension = function ( frame )
p.getExtension = function ( frame )
Zeile 1.250: Zeile 1.265:
end
end
p.failsafe = function ( frame )
p.failsafe = function ( frame )
    local s = type( frame );
     local since = frame.args[ 1 ];
     local since;
    if s == "table" then
        since = frame.args[ 1 ];
    elseif s == "string" then
        since = frame;
    end
     if since then
     if since then
         since = mw.text.trim( since );
         since = mw.text.trim( since );