@@ -0,0 +1,1652 @@
+%22%22%22Sample Wiki syntax extension plugin.%22%22%22%0A%0Afrom genshi.builder import tag%0A%0Afrom trac.core import *%0Afrom trac.util.text import shorten_line%0Afrom trac.versioncontrol.api import NoSuchChangeset%0Afrom trac.versioncontrol.web_ui import ChangesetModule%0Afrom trac.wiki.api import IWikiSyntaxProvider%0A%0Aclass RevisionLinks(Component):%0A    %22%22%22Adds a few more ways to refer to changesets.%22%22%22%0A%0A    implements(IWikiSyntaxProvider)%0A%0A    KEYWORDS = %5B'%5BRr%5Dev(?:ision)?', '%5BCc%5Dhangeset'%5D%0A%0A    # IWikiSyntaxProvider methods%0A%0A    def get_wiki_syntax(self):%0A        def revlink(f, match, fullmatch):%0A            rev = match.split(' ', 1)%5B1%5D # ignore keyword%0A            return self._format_revision_link(f, 'revision', rev, rev,%0A                                              fullmatch)%0A%0A        yield (r%22!?(?:%25s)%5Cs+%25s%22 %25 (%22%7C%22.join(self.KEYWORDS),%0A                                   ChangesetModule.CHANGESET_ID),%0A               revlink)%0A%0A    def get_link_resolvers(self):%0A        yield ('revision', self._format_revision_link)%0A%0A    def _format_revision_link(self, formatter, ns, rev, label, fullmatch=None):%0A        rev, params, fragment = formatter.split_link(rev)%0A        try:%0A            changeset = self.env.get_repository().get_changeset(rev)%0A            return tag.a(label, class_=%22changeset%22,%0A                         title=shorten_line(changeset.message),%0A                         href=(formatter.href.changeset(rev) +%0A                               params + fragment))%0A        except NoSuchChangeset:%0A            return tag.a(label, class_=%22missing changeset%22,%0A                         href=formatter.href.changeset(rev),%0A                         rel=%22nofollow%22)%0A

Add a sample self-contained IWikiSyntaxParser plugin, implementing the link revision syntax suggested in #5154.