Last modified: 2014-11-17 10:36:18 UTC
Do something as what [[X (disambiguation)|]] does.
For example: {{TRIM:X (disambiguation)}} -> X {{TRIM:Y, Jr.}} -> Y
Created attachment 6915 [details] patch to add new core parser function {{linkpst:...}} I'm not sure how this would be useful, but i made a patch which basically takes the link related stuff from Parser::pstPass2 and puts it in a core parser function named linkpst (since it essentially does the link related stuff of the pre-save-transform). {{linkpst:foo (bar)}} -> foo {{linkpst:ns:page}} -> page {{linkpst:ns:bar (baz), fred|}} -> bar etc. The only thing i'm unsure about is the regex in $p4. It doesn't appear to match stuff during pst.
Maybe it's useful in some templates, to get the name of what an article describes.
Some thoughts for the patch in comment #2: * do not use SFH_NO_HASH for new parser functions * do not duplicate code, reuse the one in Parser.php if possible * it would be very nice to have some test cases for that function in parser tests
Perhaps another parameter indicating which steps are used? {{linkpst:foo (bar)|B}} -> foo {{linkpst:foo (bar)|C}} -> foo (bar) {{linkpst:ns:page|N}} -> page {{linkpst:ns:page}} -> page {{linkpst:ns:page|N}} -> page {{linkpst:ns:page|B}} -> ns:page {{linkpst:ns:page|B}} -> ns:page {{linkpst:ns:bar (baz), fred}} -> bar {{linkpst:ns:bar (baz), fred|BC}} -> ns:bar {{linkpst:ns:bar (baz), fred|NB}} -> bar, fred {{linkpst:ns:bar (baz), fred|NC}} -> bar (baz) {{linkpst:ns:bar (baz), fred|C}} -> ns:bar (baz)
(In reply to comment #2) > I'm not sure how this would be useful... > Neither am I. (In reply to comment #3) > Maybe it's useful in some templates, to get the name of what an article > describes. > I'm not convinced. Can you explain yourself further?
For example a template {{disambig page}} with the content: '''{{linkpst:{{PAGENAME}}}}''' may refer to: {{{1}}} {{disambig}} If there's no linkpst, some pages may be displayed like: '''ABC (disambiguation)''' may be refer to: *something *something else {{disambig}}
Ignore that "be" in "'''ABC (disambiguation)''' may be refer to:" please. :)
*** This bug has been marked as a duplicate of bug 7264 ***