Changes between Version 1 and Version 2 of TracDev/PluginDevelopment/ExtensionPoints/trac.wiki.api.IWikiSyntaxProvider
- Timestamp:
- Jul 14, 2012, 7:45:50 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/PluginDevelopment/ExtensionPoints/trac.wiki.api.IWikiSyntaxProvider
v1 v2 10 10 Trac provides an extensible wiki system. Arbitrary regular expressions can be defined to match new wiki syntax. 11 11 12 For the common `namespace:target` TracLink syntax there is a special mechanism in this interface that supports registering new namespaces .12 For the common `namespace:target` TracLink syntax there is a special mechanism in this interface that supports registering new namespaces (see [[trac.resource.IResourceManager]]). 13 13 14 14 To add new functionality to the wiki system with the standardized and familiar macro or processor syntax, use a [[trac.wiki.api.IWikiMacroProvider]] instead. Often this is preferrable for more complex functionality, while syntax providers are mainly used for defining `namespace:target` links and special shortcut syntax (e.g. `{1}` instead of `report:1`). … … 18 18 Implementing the interface follows the standard guidelines found in [wiki:TracDev/ComponentArchitecture] and of course [wiki:TracDev/PluginDevelopment]. 19 19 20 A class implementing !IWikiSyntaxProvidercan define multiple link namespaces by returning their names and the corresponding resolver functions from `get_link_resolvers`.20 A class implementing `IWikiSyntaxProvider` can define multiple link namespaces by returning their names and the corresponding resolver functions from `get_link_resolvers`. 21 21 22 22 That resolver callback function is called for any matching link to be rendered, which it should do by returning the expanded HTML. … … 28 28 In both cases the callback functions receive among other parameters a `formatter` that provides access to various useful objects: 29 29 * `formatter.resource` (a [source:trunk/trac/resource.py trac.resource.Resource])[[BR]] 30 The resource identifier which owns the text being formatted. (E.g. a wiki page, where `formatter.resource.id` is the page name.) 30 The resource identifier which owns the text being formatted. (E.g. a wiki page, where `formatter.resource.id` is the page name.) In practice, it's used to identify the target URL for relative links present in that Wiki text (e.g. `[#section see Section]`) independently from where the rendered text gets displayed (in the timeline, in a report, etc.) 31 31 * `formatter.perm` (a [source:trunk/trac/perm.py trac.perm.PermissionCache])[[BR]] 32 32 The permission cache which can be used to perform fine-grained permission checks. … … 34 34 The URL builder. 35 35 * `formatter.wiki` (a [source:trunk/trac/wiki/api.py trac.wiki.api.WikiSystem])[[BR]] 36 The wiki system can be used to access wiki pages .36 The wiki system can be used to access wiki pages, settings and helper functions (e.g. `format_page_name()`). 37 37 * `formatter.wikiparser` (a [source:trunk/trac/wiki/parser.py trac.wiki.parser.WikiParser])[[BR]] 38 The wiki parser .38 The wiki parser (for now, only the constants used to form the standard regexps are there; the full "parser" is still in formatter.py for historical reasons) 39 39 * `formatter.context` (a [source:trunk/trac/mimeview/api.py trac.mimeview.api.RenderingContext])[[BR]] 40 The rendering context in which this wiki formatting takes place. 40 The rendering context in which this wiki formatting takes place. Use this rather than the `.req` to retrieve information about the author, the permissions and the like. 41 41 * `formatter.req` (a [source:trunk/trac/web/api.py trac.web.api.Request])[[BR]] 42 42 The web request. (to be deprecated) … … 73 73 * Related to the [[trac.wiki.api.IWikiMacroProvider]] 74 74 * Related tickets: 75 * [query: status=!closed&component=wiki+systemwiki system component]75 * [query:"status=!closed&component=wiki system" wiki system component] 76 76 * Related proposals: 77 77 * TracDev/Proposals/WikiParserFormatterSplit 78 78 * Related mailing list discussions: 79 * [Trac Dev:6435 IWikiSyntaxProvider match order]79 * [Trac-Dev:6435 IWikiSyntaxProvider match order] 80 80 * [source:trunk/trac/wiki/parser.py WikiParser] contains further syntax rules applied before and after the IWikiSyntaxProvider rules. 81 81 * [source:trunk/trac/wiki/formatter.py Formatter] contains further syntax rules (Font styles) applied before and after the IWikiSyntaxProvider rules.