Changeset 643
- Timestamp:
- 04/11/06 23:16:37 (3 years ago)
- Files:
-
- tocmacro/0.9/tractoc/macro.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tocmacro/0.9/tractoc/macro.py
r615 r643 13 13 class NullOut(object): 14 14 def write(self, *args): pass 15 16 17 class MyOutlineFormatter(OutlineFormatter): 18 19 def format(self, page, *args, **kwords): 20 self.__page = page 21 super(MyOutlineFormatter,self).format(*args, **kwords) 22 23 def _heading_formatter(self, match, fullmatch): 24 Formatter._heading_formatter(self, match, fullmatch) 25 depth = min(len(fullmatch.group('hdepth')), 5) 26 heading = match[depth + 1:len(match) - depth - 1] 27 anchor = self._anchors[-1] 28 text = wiki_to_oneliner(heading, self.env, self.db, self._absurls) 29 text = re.sub(r'</?a(?: .*?)?>', '', text) # Strip out link tags 30 self.outline.append((depth, '<a href="%s#%s">%s</a>' % (self.__page, anchor, text))) 15 31 16 32 class TracTocMacro(Component): … … 51 67 def render_macro(self, req, name, args): 52 68 db = self.env.get_db_cnx() 53 formatter = OutlineFormatter(self.env)69 formatter = MyOutlineFormatter(self.env) 54 70 55 71 # If this is a page preview, try to figure out where its from … … 122 138 page_text, _ = get_page_text(page) 123 139 124 formatter.format(page_text, NullOut(), 1, 1) 125 self.log.debug(page + ' --> ' + repr(formatter.outline)) 140 formatter.format(page, page_text, NullOut(), 1, 1) 126 141 header = '' 127 142 if formatter.outline: … … 137 152 page_text, page_exists = get_page_text(page) 138 153 if page_exists: 139 formatter.format(page _text, out, params['min_depth'], params['max_depth'])154 formatter.format(page, page_text, out, params['min_depth'], params['max_depth']) 140 155 else: 141 156 out.write('<div class="system-message"><strong>Error: Page %s does not exist</strong></div>' % pagename)
