LazyWebLinks
Goal
Cause markup text beginning with "www." to be automatically converted into a link to an external site.
Solution
Add the following code to a local customization file:
Markup('lazyweb','<wikilink', "/\\bwww\\.[^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars]/", "LazyWebLinks"); function LazyWebLinks($m) { extract($GLOBALS["MarkupToHTML"]); # get $pagename return Keep(MakeLink($pagename, 'http://'.$m[0], $m[0]), 'L'); }
Discussion
This recipe causes any text beginning with "www.", such as www.pmwiki.org, to be automatically converted to an http-link to an external site. This recipe has been enabled on this page to allow experimentation.
Does this recipe "play nicely" with Approve URLs? Doesn't seem to be working below... --Peter Bowers July 18, 2010, at 01:55 PM
See PITS:00036 (Main.ApprovedUrls doesn't work with Cookbook.LazyWebLinks). --Petko July 18, 2010, at 03:16 PM
Contributors
Sandbox
- www.pmichaud.com
- www.google.com
- pmwiki.org
- [(approve links) edit diff]
- http://kiwiwiki.co.nz
- abc.[(approve links) edit diff]
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.