[pmwiki-users] %id=some-label% markup
Patrick R. Michaud
pmichaud at pobox.com
Mon Jun 26 22:38:51 CDT 2006
On Tue, Jun 27, 2006 at 11:22:23AM +1200, John Rankin wrote:
> On Monday, 26 June 2006 3:19 PM, John Rankin <john.rankin at affinity.co.nz> wrote:
> >It appears that %id=some-label% gets turned into id="some_label"
> >on output. Is there a reason for this? AFAIK hyphens are allowed
> >in id attribute values.
> >The wikistyles.php code does this deliberately:
> >.... if ($k=='id') $id = preg_replace('/\W/','_',$v);
The purpose of the replacement here is not to protect against
hyphens, but rather to protect against other characters that
someone might put in an id (space being one of the most
prominent). I didn't recall that hyphen, colon, and dot were
also valid id characters.
The HTML4 spec  says:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may
be followed by any number of letters, digits ([0-9]),
hyphens ("-"), underscores ("_"), colons (":"), and
Thus, I'll change the wikistyles code to instead read
if ($k=='id') $id = preg_replace('/[^-A-Za-z0-9:_.]+/','_',$v);
which will replace all non-HTML4 compliant characters with underscores.
> And I think there is a bug in the figure caption markup...
> %id=sample.figure%Attach:some.image.gif | With a caption
> The dot in the id (which gets turned into a '_') causes the
> caption match to fail. A dot is omitted from the list of
> style characters caption markup matches on.
You're correct, this is a bug.
Both of the above are now fixed on pmwiki.org (so you can test them
if you'd like), and will appear in the next release.
More information about the pmwiki-users