[pmwiki-users] brackets in link alt/title text

John Rankin john.rankin at affinity.co.nz
Mon May 23 04:08:21 CDT 2011

A couple of weeks ago on the developers' list, I raised a minor issue of
brackets in link alt or title text being removed. The work-around was to
use numeric entities (( and )). This was in the context of a local
customisation to support markup like:

[[Kororareka"Kororareka ¶ A Mixed Community ¶ Shulitea (King

One would rather write:

[[Kororareka"Kororareka ¶ A Mixed Community ¶ Shulitea (King

I think this could be supported with a minor change to the MakeLink
function in pmwiki.php:

function MakeLink($pagename,$tgt,$txt=NULL,$suffix=NULL,$fmt=NULL) {
#  $t = preg_replace('/[()]/','',trim($tgt));
#  $t = preg_replace('/<[^>]*>/','',$t);
#  preg_match("/^($LinkPattern)?(.+?)(\"(.*)\")?$/",$t,$m);
  $t = preg_replace('/<[^>]*>/','',trim($tgt));
  if (preg_match('/^(.+?)("(.*)")$/',$t,$mt)) $t = $mt[1];
  $t = preg_replace('/[()]/','',$t);

[ ...]

  $out = $LinkFunctions[$m[1]]($pagename,$m[1],$m[2],@$mt[3],$txt,$fmt);
#  $out = $LinkFunctions[$m[1]]($pagename,$m[1],$m[2],@$m[4],$txt,$fmt);
  return $out;

The commented lines are the original pmwiki code. The change removes
optional "alt text" from the $tgt *before* removing ( and ). The change
will also correctly process markup like:

[[http://example.org"a (possibly) relevant example" | this case]]

I think this change would be harmless and consistent with image alt text,
in which brackets are fine.

John Rankin

More information about the pmwiki-users mailing list