Edgewall Software
Modify

Opened 20 years ago

Closed 20 years ago

Last modified 18 years ago

#847 closed defect (fixed)

Add 'id' attribute to headings in the wiki

Reported by: dmurphy25@… Owned by: Jonas Borgström
Priority: normal Milestone: 0.9
Component: wiki system Version: 0.8
Severity: normal Keywords:
Cc: manuzhai@…, trac-form@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christopher Lenz)

By adding the 'id' attribute to the h* elements in the wiki, it would be possible to link to both a page and a specific section of the page.

e.g.

== Versions ==

…would become…

<h2 id="versions">Versions</h2>

… and could be linked to with [wiki:SomePage#versions].

It would also need to correct case/replace spaces with underscores in both the tag generation and link parsing.

Attachments (0)

Change History (13)

comment:1 by Christopher Lenz, 20 years ago

Why not add an id to any heading level?

comment:2 by dmurphy25@…, 20 years ago

You're quite right - this should apply automatically to all hn elements.

comment:3 by Christopher Lenz, 20 years ago

Keywords: id tag removed
Summary: Add 'id' attribute to h2 elements in the wikiAdd 'id' attribute to headings in the wiki

comment:4 by Christopher Lenz, 20 years ago

Description: modified (diff)

Ticket #992 has been marked as duplicate of this ticket. It contains a couple of patches.

comment:5 by anonymous, 20 years ago

Cc: manuzhai@… added

comment:6 by trac-form@…, 20 years ago

Cc: trac-form@… added

I have fixed all of cmlenz's issues with the original patch in #992. The fix for anchor uniqueness is based off the patch submitted by Manuzhai. I have also modified the TOC macro to use unique anchors and fixed a few other issues.

Patch is available here and TOC macro here.

comment:7 by trac-form@…, 20 years ago

Actually, make that all of cmlenz's issues except the unit tests

;)

comment:8 by Christopher Lenz, 20 years ago

Milestone: 0.9
Resolution: fixed
Status: newclosed

Implemented in [1250].

For the TOC macro, note that IDs starting with a digit are prefixed with an underscore. So the macro will probably need to be updated.

comment:9 by nil4@…, 20 years ago

Resolution: fixed
Severity: enhancementnormal
Status: closedreopened
Version: 0.7.10.8

To prevent anchor ids incrementing their numerical suffix forever, you should add a line:

class WikiFormatter:
  def __init__:
    ...
    self.anchors = []

Otherwise, every visit (or refresh) of the same wiki page generates different heading ids.

comment:10 by Matthew Good <trac matt-good net>, 20 years ago

Well, I should note that the above id incrementing may not occur under CGI since the CGI will be run as a new process each time. So, I think that the anchor resetting would need tested under mod_python to reproduce the problem.

comment:11 by Christopher Lenz, 20 years ago

Resolution: fixed
Status: reopenedclosed

Thanks, fixed in [1301].

comment:12 by nil4@…, 20 years ago

Matthew: Sorry, I forgot to mention this issue occured under mod_python. The proposed patch fixes this problem.

cmlenz: Thanks for your quick reaction, and congratulations for making this outstanding product available to us all.

comment:13 by nil4@…, 20 years ago

Matthew: Sorry, I forgot to mention this issue occured under mod_python. The proposed patch fixes this problem.

cmlenz: Thanks for your quick reaction, and congratulations for making this outstanding product available to us all.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.