=== trac/Ticket.py
==================================================================
|
|
|
|
| 401 | 401 | self.req.hdf.setValue('title', '#%d (%s)' % (id,ticket['summary'])) |
| 402 | 402 | self.req.hdf.setValue('ticket.description.formatted', |
| 403 | 403 | wiki_to_html(ticket['description'], self.req.hdf, |
| 404 | | self.env, self.db)) |
| | 404 | self.env, self.db, |
| | 405 | module=self._name, id=str(id))) |
| 405 | 406 | self.req.hdf.setValue('ticket.opened', time.strftime('%c', time.localtime(int(ticket['time'])))) |
| 406 | 407 | |
| 407 | 408 | changelog = ticket.get_changelog(self.db) |
| … |
… |
|
| 418 | 419 | hdf.setValue('ticket.changes.%d.old' % idx, util.escape(old)) |
| 419 | 420 | if field == 'comment': |
| 420 | 421 | hdf.setValue('ticket.changes.%d.new' % idx, |
| 421 | | wiki_to_html(new, self.req.hdf, self.env, self.db)) |
| | 422 | wiki_to_html(new, self.req.hdf, self.env, self.db, |
| | 423 | module=self._name, id=str(id))) |
| 422 | 424 | else: |
| 423 | 425 | hdf.setValue('ticket.changes.%d.new' % idx, util.escape(new)) |
| 424 | 426 | idx = idx + 1 |
=== trac/Wiki.py
==================================================================
|
|
|
|
| 336 | 336 | self.req.hdf.setValue('wiki.page_name', self.page.name) |
| 337 | 337 | self.req.hdf.setValue('wiki.page_source', escape(self.page.text)) |
| 338 | 338 | out = StringIO.StringIO() |
| 339 | | Formatter(self.req.hdf, self.env,self.db).format(self.page.text, out) |
| | 339 | Formatter(self.req.hdf, self.env,self.db, module=self._name, id=self.page.name).format(self.page.text, out) |
| 340 | 340 | self.req.hdf.setValue('wiki.page_html', out.getvalue()) |
| 341 | 341 | |
| 342 | 342 | def display_txt(self): |
=== trac/WikiFormatter.py
==================================================================
|
|
|
|
| 265 | 265 | r"""(?P<imgurl>!?([a-z]+://[^ ]+)\.(PNG|png|JPG|jpg|JPEG|jpeg|GIF|gif)(\?\S+)?)""", |
| 266 | 266 | r"""(?P<url>!?([a-z]+://[^ ]+[^\.,' \)\]\}]))""", |
| 267 | 267 | r"""(?P<last_table_cell>\|\|$)""", |
| 268 | | r"""(?P<table_cell>\|\|)"""] |
| | 268 | r"""(?P<table_cell>\|\|)""", |
| | 269 | r"""(?P<attachmentlink>!?(?P<a_type>img|attachment):(?P<a_file>[^? ]+))"""] |
| 269 | 270 | |
| 270 | 271 | _compiled_rules = re.compile('(?:' + string.join(_rules, '|') + ')') |
| 271 | 272 | _processor_re = re.compile('#\!([a-zA-Z0-9/+-]+)') |
| … |
… |
|
| 275 | 276 | # RE patterns used by other patterna |
| 276 | 277 | _helper_patterns = ('idepth', 'ldepth', 'hdepth', 'fancyurl', |
| 277 | 278 | 'linkname', 'macroname', 'macroargs', 'inline', |
| 278 | | 'modulename', 'moduleargs') |
| | 279 | 'modulename', 'moduleargs', |
| | 280 | 'a_type', 'a_file') |
| 279 | 281 | |
| 280 | 282 | _htmlproc_disallow_rule = re.compile('(?i)<(script|noscript|embed|object|iframe|frame|frameset|link|style|meta|param|doctype)') |
| 281 | 283 | |
| | 284 | def __init__(self, hdf, env, db, absurls=0, module=None, id=None): |
| | 285 | CommonFormatter.__init__(self, hdf, env, db, absurls) |
| | 286 | self.module = module |
| | 287 | self.id = id |
| | 288 | |
| 282 | 289 | def default_processor(hdf, text, env): |
| 283 | 290 | return '<pre class="wiki">' + util.escape(text) + '</pre>' |
| 284 | 291 | def asp_processor(hdf, text, env): |
| … |
… |
|
| 374 | 381 | def _imgurl_formatter(self, match, fullmatch): |
| 375 | 382 | return '<img src="%s" alt="%s" />' % (match, match) |
| 376 | 383 | |
| | 384 | def _attachmentlink_formatter(self, match, fullmatch): |
| | 385 | if match[0] != '!': |
| | 386 | type = fullmatch.group('a_type') |
| | 387 | file = fullmatch.group('a_file') |
| | 388 | format = None |
| | 389 | if type == 'img': |
| | 390 | return '<img src="%s" alt="%s" />' % ( |
| | 391 | self._href.attachment(self.module, self.id, file, 'raw'), file) |
| | 392 | else: |
| | 393 | return '<a href="%s" title="%s">%s</a>' % ( |
| | 394 | self._href.attachment(self.module, self.id, file), file, match) |
| | 395 | |
| 377 | 396 | def _indent_formatter(self, match, fullmatch): |
| 378 | 397 | depth = int((len(fullmatch.group('idepth')) + 1) / 2) |
| 379 | 398 | list_depth = len(self._list_stack) |
| … |
… |
|
| 587 | 606 | self.close_list() |
| 588 | 607 | |
| 589 | 608 | |
| 590 | | def wiki_to_html(wikitext, hdf, env, db, absurls=0): |
| | 609 | def wiki_to_html(wikitext, hdf, env, db, absurls=0, module=None, id=None): |
| 591 | 610 | out = StringIO.StringIO() |
| 592 | | Formatter(hdf, env, db, absurls).format(wikitext, out) |
| | 611 | Formatter(hdf, env, db, absurls, module, id).format(wikitext, out) |
| 593 | 612 | return out.getvalue() |
| 594 | 613 | |
| 595 | 614 | def wiki_to_oneliner(wikitext, hdf, env, db,absurls=0): |