Opened 11 years ago

Closed 11 years ago

# 0.10-incompatibility: Broken.

Reported by: Owned by: Dinko Korunic Alec Thomas normal TocMacro normal toc, formatter 0.10

### Description

With Trac trunk (r3411) it stopped working with KeyError (check attached log). Code according to backtrace seems this section:

def _heading_formatter(self, match, fullmatch):
...
anchor = self._anchors[-1]
...


I have modified it to the following (code taken from Trac Wiki formatter directly):

def _heading_formatter(self, match, fullmatch):
...
anchor = fullmatch.group('hanchor') or ''
...


Seems to be working now. Hope this helps.

### Changed 11 years ago by Dinko Korunic <dinko.korunic@…>

Trac backtrace of TocMacro error

### comment:1 in reply to:  description ; follow-up:  2 Changed 11 years ago by anonymous

With Trac trunk (r3411) it stopped working with KeyError (check attached log).

Actually, this changed in [T3408].

def _heading_formatter(self, match, fullmatch):
...
anchor = fullmatch.group('hanchor') or ''
...


No, that's not a correct fix. See the abovementioned change for an example about how to get the anchor. The hanchor group is for an optional, explicitely given id, which, most of the time, will not be given.

### comment:2 in reply to:  1 Changed 11 years ago by Christian Boos

Replying to anonymous: ... That anonymous was me (and the above comment made me spot a little bug with the reply to description feature, which I just fixed [T3412])

### Changed 11 years ago by Christian Boos

TocMacro's macro.py file updated for 0.10. Time to make a new branch for it! The macro has not been thoroughly tested, but this appears to work. Compatible with [T3412]. (take 2)

### comment:3 Changed 11 years ago by Dinko Korunic <dinko.korunic@…>

You're right, I've just checked. Thanks. Will checkout latest TocMacro.

### comment:4 Changed 11 years ago by Max Bowsher

Whilst MyOutlineFormatter.format is being tweaked, purely as a clarification, the following three lines could be moved outside the enclosing for loop:

36 	            active = ''
37 	            if page == active_page:
38 	                active = ' class="active"'


...since neither page nor active_page changes from one loop iteration to the next.

### comment:5 Changed 11 years ago by Max Bowsher

Trac Release: 0.9 → 0.10

### comment:6 Changed 11 years ago by Max Bowsher

cboos' macro.py suffers from inconsistent indentation schemes, and also, I think, introduces some bugs by accidentally shifting some statements to different block levels.

I've cleaned up the indentation and put the shifted statements back to their original block level, and am attaching the result as a patch....

### Changed 11 years ago by Max Bowsher

The effective changes from cboos' macro.py, cleaned up and shown as a patch

### comment:7 Changed 11 years ago by Christian Boos

Right, I remember I had trouble with the indentation, not sure why, as the original file seems to be correctly indented.

I could make a 0.10 version using your patch (+ the other change you suggested), if athomas would give me the perms for that plugin...

### comment:8 Changed 11 years ago by Max Bowsher

Summary: Stopped working with trac trunk, error in using anchor → 0.10-incompatibility: Broken.

I've split up cboos' patch into multiple changes:

• fix441: Fix this ticket. (also, added the change I suggested in comment:4)
• tweaks: General refactoring.
• linewrap: Wrap overly long lines.
• wmbref: Convert to WikiMacroBase.

(These should be applied in that order - they have interdependencies.)

• Removal of trailing whitespace: I've not included that in the above patches, since it is easier for a committer to run a simple editor command, than review a patch doing the same (but it would be nice to have this done).
• Introduction of coding: utf-8 statement: I've dropped that, since it was only there to support the addition of a weird angled quote character in an added comment, which looked like a typo anyway.
• Placing of an assignment to args into an else: clause: I've removed this change, since it results in args being a different datatype (string vs. list) depending on whether args are provided, which doesn't seem right.
• A couple of odd whitespace changes within lines: I left these out.

I will now attach the 5 patch files.

See comment:8

See comment:8

See comment:8

See comment:8

See comment:8

### comment:9 Changed 11 years ago by Max Bowsher

Oops! There's an error in various places throughout cboos' macro.py and my derivatives:

out.write(system_message(MESSAGE), None)


is supposed to be:

out.write(system_message(MESSAGE, None))


The error is present in the first of two uses of system_message in macro.py. In tweaks.patch, I accidentally spread the error to the second use too. In linewrap.patch, there's one change which isn't a pure line-wrap: the accidental spreading is undone again.

Rather than re-attaching fixed versions of tweaks.patch and linewrap.patch, please just correct the placement of the parentheses as described above, in tweaks.patch and linewrap.patch, before applying them - thanks!

### comment:10 Changed 11 years ago by Noah Kantrowitz

Resolution: → fixed new → closed

(In [927]) Intergrating several patches from #441. Thanks to cboos and maxb for sorting this out. Closes #441.

### comment:11 Changed 11 years ago by Christian Boos

Yep, thanks for the fixes to my fixes, maxb :)

Also, the system_message was slightly improved in [T3431].

Lastly, don't hesitate to comment and brainstorm further relative to the attachment:011notes.patch

### Modify Ticket

Change Properties