Edgewall Software

Changes between Version 3 and Version 4 of TracDev/IWikiSyntaxProviderExample


Ignore:
Timestamp:
Sep 11, 2010, 11:41:13 AM (14 years ago)
Author:
Christian Boos
Comment:

Improve the sample code (PEP:0008, TracDev/CodingStyle) and answer the question about regexp capture groups

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/IWikiSyntaxProviderExample

    v3 v4  
    135135{{{
    136136#!python
    137 # encoding: utf-8
     137# -*- coding: utf-8 -*-
    138138"""
    139139WikiSyntaxProviderTest.py
     
    143143"""
    144144
     145from genshi.builder import tag
     146
    145147from trac.core import *
    146148from trac.wiki import IWikiSyntaxProvider
    147 from genshi.builder import tag
     149
    148150
    149151class WikiSyntaxProviderTest(Component):
    150     '''This is a test Component to demonstrate the use of the IWikiSyntaxProvider Interface of Trac.'''
     152    """This is a test Component to demonstrate the use of the
     153    IWikiSyntaxProvider Interface of Trac."""
    151154    implements(IWikiSyntaxProvider)
    152155
     
    157160
    158161    def get_wiki_syntax(self):
    159         #group numbers dont work, why? Must use group names inside the regex.
    160         yield ( r'\?(?P<domain>[tmw])_(?P<searchword>.+?)\?', self._format_regex_link)
     162        # Note that group numbers don't work as the following is only a regexp
     163        # fragment which will be part of a larger regexp, therefore one must
     164        # use group names, with reasonably unique names
     165        yield (r'\?(?P<domain>[tmw])_(?P<searchword>.+?)\?',
     166               self._format_regex_link)
    161167
    162168    def _format_regex_link(self, formatter, ns, match):