Edgewall Software
Modify

Ticket #847 (closed defect: fixed)

Opened 7 years ago

Last modified 5 years ago

Add 'id' attribute to headings in the wiki

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

Description (last modified by cmlenz) (diff)

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

Change History

comment:1 Changed 7 years ago by cmlenz

Why not add an id to any heading level?

comment:2 Changed 7 years ago by dmurphy25@…

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

comment:3 Changed 7 years ago by cmlenz

  • Keywords id tag removed
  • Summary changed from Add 'id' attribute to h2 elements in the wiki to Add 'id' attribute to headings in the wiki

comment:4 Changed 7 years ago by cmlenz

  • Description modified (diff)

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

comment:5 Changed 7 years ago by anonymous

  • Cc manuzhai@… added

comment:6 Changed 7 years ago by trac-form@…

  • 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 Changed 7 years ago by trac-form@…

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

;)

comment:8 Changed 7 years ago by cmlenz

  • Milestone set to 0.9
  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 7 years ago by nil4@…

  • Resolution fixed deleted
  • Severity changed from enhancement to normal
  • Status changed from closed to reopened
  • Version changed from 0.7.1 to 0.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 Changed 7 years ago by Matthew Good <trac matt-good net>

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 Changed 7 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from reopened to closed

Thanks, fixed in [1301].

comment:12 Changed 7 years ago by nil4@…

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 Changed 7 years ago by nil4@…

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.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from jonas. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.