Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:WLink/doc
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{High-use}} {{Module rating|release}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> '''<code>WLink</code>''' β Module with functions for strings in context of wikilinks and external links ([[Uniform Resource Locator|URL]]). This module was imported from [[:de:Module:WLink]]. == Usage == All functions expect exactly one unnamed parameter (which should be provided to get a meaningful answer). Whitespace ahead and after content is ignored. HTML Entities would not disturb syntax and might be resolved. The parameter might contain single or double bracketed links which would be extracted if appropriate. The return value is an empty string (βnothingβ), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space. ; ansiPercent : Convert string by ANSI encoding rather than UTF-8 encoding : Required for some 20<sup>th</sup> century servers : Optional parameter <code>space</code> β encoding of spaces: :* <code>space=+</code> β common for query components :* <code>space=_</code> β as for Wikis :* Default: <code>%20</code> ; formatURL : Create bracketed link, if not yet, from URL or domain :* <nowiki>[http://example.org/about Homepage]</nowiki> ''yields'' <nowiki>[http://example.org/about Homepage]</nowiki> :* <nowiki>http://example.org/about</nowiki> ''yields'' <nowiki>[http://example.org/about example.org/about]</nowiki> :* example.org ''yields'' <nowiki>[http://example.org/ example.org]</nowiki> ; getArticleBase : Retrieve generic page title, no fragment nor brackets : Use current page title, if omitted. ; getBaseTitle : Retrieve last segment in subpage, no fragment ; getExtension : Retrieve media extension : Result is downcased (without leading dot). ; getFile : Retrieve media page identifier ; getFragment : Retrieve original (not decoded) fragment string after <code>#</code> ; <s>getLanguage</s> : Retrieve language identifier ; <s>getNamespace</s> : Retrieve namespace number ; getPlain : Retrieve text with all links replaced by link titles ; <s>getProject</s> : Retrieve project identifier within wikifarm (recommendable brief notation) ; getTarget : Retrieve first target (wikilink or URL) ; getTargetPage : Retrieve first target page (page name or URL of page) : Same as ''getTarget'' if no fragment. ; getTitle : Retrieve first link title (wikilink or URL), or wikilink target ; isBracketedLink : Does attempt match a bracketed link? ; isBracketedURL : Does attempt match a bracketed URL? ; isCategorization : Does attempt match a categorization? ; isExternalLink : Does attempt match an external link? ; isInterlanguage : Does attempt match an interlanguage link? ; isInterwiki : Does attempt match an interwiki link? ; isMedia : Does attempt match a media translusion? ; isTitledLink : Does attempt match a titled link? ; isValidLink : Does attempt match a link? ; isWeblink : Does attempt match an external link? ; isWikilink : Does attempt match a wikilink? ; failsafe : Version ID: <code>{{#invoke:WLink|failsafe}}</code> : optional parameter <code>1</code> β required version :: result: empty, if requirement not met === Examples (test page) === A [[:de:Wikipedia:Lua/Modul/WLink/Test|test page]] illustrates practical use. == Functions for Lua modules (API) == {{anchor|Lua}} All functions described above can be used by other modules: <syntaxhighlight lang="lua"> local lucky, WLink = pcall( require, "Module:WLink" ) if type( WLink ) == "table" then WLink = WLink.WLink() else -- failure; WLink is the error message return "<span class=\"error\">" .. WLink .. "</span>" end </syntaxhighlight> Subsequently there are available: * WLink.ansiPercent(story, space) * WLink.formatURL() * WLink.getArticleBase() * WLink.getBaseTitle() * WLink.getExtension() * WLink.getFile() * WLink.getFragment() *: <code>false</code>, if not found; but empty string if empty fragment. *: No leading <code>#</code> in result. * WLink.getLanguage() * WLink.getNamespace() * WLink.getPlain() * WLink.getProject() * WLink.getTarget() * WLink.getTargetPage() * WLink.getTitle() * WLink.isBracketedLink() * WLink.isBracketedURL() * WLink.isCategorization() * WLink.isExternalLink() * WLink.isInterlanguage() * WLink.isInterwiki() * WLink.isMedia() * WLink.isTitledLink() * WLink.isValidLink() * WLink.isWeblink() * WLink.isWikilink() * WLink.wikilink() *: Yields ''table'' with wikilink components, else <code>false</code>. *: Components might be, if provided: *:* <code>lead</code> β leading colon <code>:</code> present and required, if <code>true</code> *:* <code>project</code> β project interwiki within wikifarm (recommendable brief notation) *:* <code>lang</code> β known language version (downcased) *:* <code>ns</code> β number of namespace *:* <code>space</code> β local canonical name of namespace *:* <code>title</code> β page title as provided; at least empty string * WLink.failsafe(atleast) *:# atleast<br />''optional''<br />''nil'' or required version *: returns: ''string'' or ''false'' If succeeding, the ''WLink.get*()'' return a string, the ''WLink.is*()'' <code>true</code> (if no exception mentioned); on failure always <code>false</code>.
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Anchor
(
edit
)
Template:Error
(
edit
)
Template:High-use
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:WLink
(
edit
)