Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AtLinks

Summary: Alternative linking scheme with @ prefix (@Page)
Version: 5 Feb. 2005
Status: Stable
Prerequisites: pmwiki-2
Maintainer: PRZ
Categories: Links, Editing
Votes:

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)/e",
  "Keep(MakeLink(\$pagename,PSS('$2'),CHX(PSS('$2'),PSS('$3')),'$4'),'L')");

## @link (after a non alphanum char)
Markup('@','<wikilink',
  "/(?<![[:alnum:]])@([[:alnum:]\\.\\/\\-_]+[[:alnum:]])/e",
  "Keep(MakeLink(\$pagename,PSS('$1'),NULL,NULL),'L')");

## @link @"text -> target" 		  
Markup('@->','<@_',
  "/@(\\x22)([^\\x22]+?)\\s*-+&gt;\\s*(\\S[^\\x22]+?)\\x22/e",
  "Keep(MakeLink(\$pagename,PSS('$3'),PSS('$2'),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

S dlink? makeunivers?

a link? Test.another link? ` is? not ok

text? , 2texte? - 3texte?

txt1?,txt2?

-one link ?- -l'élément?

skin config text?

textual? - txt2?

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"

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

Discussion

The risk is to break standards, if you wish to exchange pages with others wiki.

This can also be studied as exchange to double brackets when posting, with ROSPatterns function, but it will lost a part of the interest, which is a better readability than double brackets markup.

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

Comments

Is it possible to activate it on the page ?

Done 31-Jan-2005. I haven't tested it. --Pm
Thanks, that works ! PRZ

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')");

Edit - History - Print - Recent Changes - Search
Page last modified on July 10, 2007, at 04:16 PM