AtLinks
Goal
Provide an alternative solution to build links by prefixing the page names with an @
Solution
Set in the file local/config.php the following lines:
function CHX($x,$y) { if ($y=='') return NULL; return $y; } ## @"target | text" or @'target | text' or @'target ; tex't or @"target, tx" Markup('@_','links',"/@([\\x22\\x27])([^|,;]+?)(?:[|,;](.*?))*\\1($SuffixPattern)/", "mu_atlinks1"); function mu_atlinks1($m) { extract($GLOBALS['MarkupToHTML']); return Keep(MakeLink($pagename,$m[2],CHX($m[2],$m[3]),$m[4]),'L'); } ## @link (after a non alphanum char) Markup('@','>urllink',"/(?<![[:alnum:]])@([^\\x22\\x27](?:-?[[:alnum:]\\/]+)*)/", "mu_atlinks2"); function mu_atlinks2($m) { extract($GLOBALS['MarkupToHTML']); return Keep(MakeLink($pagename,$m[1],NULL,NULL),'L'); }
This work in addition to existing linking, the usual linking stuff remains active.
Usage
@cat , -@dog ...@Test/bear @CNC25 - Address : toto@wanadoo.fr S @dlink make@"univers" @"Test/a link" @"Test.another link" `@ is not ok @"target|text" , @"target2,2text"e - @'target3 ; 3text'e @'Test/lnk1;txt1',@"Test/lnk2;txt2" -@"one link "- -@"l'élément" @"skin config" @"Test.link | text" @"Test.link, text"ual - @"Test.lnk2, txt2" |
cat? , -dog? ...bear? CNC25? - Address : toto@wanadoo.fr |
This is quite flexible, you can use as text separator | or , or ;
and as container ' or " so it is possible to have ' in the text. By example :
@"PmWikiFr/Conseils pour l'édition" |
Though the notation @"text -> target"
works only with double quotes
See an example here :
http://www.rouzeau.net/w3/pmwiki.php?pagename=Main.HomePage
Restrictions
That don't work in PmWiki/WikiTrails
See also
This is based on suggestion done on the mailing list by Fred Chittenden - see http://www.pmichaud.com/pipermail/pmwiki-users/2004-October/006906.html
History
- On the mailing list on October 14, 2004
- Issued on the cookbook January 02, 2005
- Works ok in config.php file January 30, 2005
- Added
@"text -> target"
and modified@Target
feb 8, 2005 - Corrected problem with
@WikiWord
feb 12, 2005
Contributors
Sandbox
Old stuff - still active on this page
function CHX($x,$y) { if ($y=='') return NULL; return $y; } ## @"target | text" or @'target | text' or @'target ; tex't or @"target, tx" Markup('@_','links',"/@([\\x22\\x27])([^|,;]+?)(?:[|,;](.*?))*\\1($SuffixPattern)/e", "Keep(MakeLink(\$pagename,PSS('$2'),CHX(PSS('$2'),PSS('$3')),'$4'),'L')"); ## @link (after a non alphanum char) Markup('@','>urllink',"/(?<![[:alnum:]])@([^\\x22\\x27](?:-?[[:alnum:]\\/]+)*)/e", "Keep(MakeLink(\$pagename,PSS('$1'),NULL,NULL),'L')");
Comments
See discussion at AtLinks-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.