[pmwiki-users] Setting an id-tag to a 2nd level heading and removing "name=" in anchor

Hans design5 at softflow.co.uk
Tue Mar 22 12:56:09 CDT 2011


Tuesday, March 22, 2011, 5:21:52 PM, Martin Kerz wrote:

> is it possible to ad an id-tag to a 2nd level heading?

> I need html that looks like this:

> <h2 id="heading">Heading</h2>

This may work for you:
add to config:

## headings with id
Markup('^!id!', '<^!',
  '/^(!{1,6})([A-Za-z][-.:\\w]*)!\\s?(.*)$/e',
  "'<:block,1><h'.strlen('$1').' id=\"$2\"'.PSS('>$3</h').strlen('$1').'>'");

and in a page use like this:

!!idname! Heading text heading two

!!!anotherid! Heading three

Basically exclamation marks like in standard heading markup, followed
by id-name, followed by another ! followed by the usual heading text.
Ids start with  a letter, same as for anchors.
No spaces between initial !! and id and following !.

The markup rule is set to come before the standard headings markup,
otherwise it would not be caught.

cheers,
  ~Hans




More information about the pmwiki-users mailing list