Last modified: 2011-04-14 15:12:56 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 16080 - RFE: ParserFunction to extract one or the other part of a wikilink
RFE: ParserFunction to extract one or the other part of a wikilink
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-23 22:13 UTC by cypsy
Modified: 2011-04-14 15:12 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description cypsy 2008-10-23 22:13:33 UTC
Request for enhancement: A parser function that can extract part of a wikilink

I imagine such a parser function would/could work something like this:
{{#linkpart: [[foo|bar]] }} => bar    //returns the link's presentation text
{{#linkpart: [[foo|bar]]:R }} => foo  //returns the "raw", i.e. the link's target

{{#linkpart: [[foo]] }} => foo        //presentation form and raw form are identical
{{#linkpart: [[foo]]:R }} => foo      //... so both return the same thing

{{#linkpart: plaintext }} => plaintext // a non-link returns plain text

Rationale: Such a function is necessary for parameter handling in templates (e.g. to 
deal with links when one isn't expected), and to be able to generate clean metadata. For example, invoking {{cite|title=[[foo|bar]] }} will be appear "fine" in an article, but the metadata (invisible to the editor) will end up with the wiki syntax too, as in: 
<span title="ctx_ver=Z39.88-2004&rft.btitle=[[foo|bar]]"> (the urlencoded version thereof)
Comment 1 Danny B. 2008-10-23 22:23:17 UTC
To find out if it's a link or not - if you know that only existing pages are linked - you can use {{#ifexist:}}.
Comment 2 cypsy 2008-10-24 11:46:56 UTC
(In reply to comment #1)
> To find out if it's a link or not - if you know that only 
> existing pages are linked - you can use {{#ifexist:}}.

* This RFE has nothing directly to do with determining whether a parameter 
  is a link or not. What this RFE does is request a particular kind 
  of (wikisyntax-specific) string manipulation, i.e. to extract one part
  of what is inside a [[ ]]. See also {{#titleparts:}}
* Its not meaningful for a template to simply determine if a parameter 
  is a link. The template couldn't do anything about it.
* {{#ifexist:}} cannot in fact be reliably (mis)used to determine if a 
  parameter is a link. Case in point: 'bugzilla:16080' and 
  'm:Parser functions' will "not exist", nor will anything else that 
  needs "parsing", like '2008-10-24' or for that matter anything 
  '[[like this]]' (which would be "expected" use of the suggested 
  {{#linkparts:}})
* Now that you mention it (and although not related to the rationale 
  for this RFE), simply determining if a parameter is a link can 
  (also) be determined using the suggested {{#linkpart}} syntax 
  mentioned above, but even then, its not altogether trivial: 
  {{#ifeq:{{#linkpart:{{{1|+}}}}}|{{{1|-}}}||Param #1 is a wikilink!}}
  would be the most basic form. And a more robust implementation would 
  still fail if {{{1}}} has internal leading/trailing whitespace.
  
I repeat: This RFE has nothing directly to do with determining whether a 
parameter is a link or not. Together with #ifeq it can /also/ be used to 
determine that, but that is not its basic function. The basic function is 
a particular kind of (wikisyntax-specific) string manipulation.



Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links