The wiki module presents several possibilities of extension, for interacting with the Wiki application and also for extending the Wiki syntax.
First, components can be notified of the changes happening in the wiki.
Components that want to get notified about the creation, deletion and modification of wiki pages should implement that interface.
See also trac.wiki.api.IWikiChangeListener extension point.
Called whenever a new Wiki page is added.
Called when a page has been modified.
Since 1.0.3: | ipnr is optional and deprecated, and will be removed in 1.3.1 |
---|
Called when a page has been deleted.
Called when a page has been renamed.
Called when a version of a page has been deleted.
Components can also interfere with the changes, before or after they’re made.
Components that need to do specific pre- and post- processing of wiki page changes have to implement this interface.
Unlike change listeners, a manipulator can reject changes being committed to the database.
See also trac.wiki.api.IWikiPageManipulator extension point.
Validate a wiki page before rendering it.
Parameters: |
|
---|
Validate a wiki page after it’s been populated from user input.
Parameters: | page – is the WikiPage being edited. |
---|---|
Returns: | a list of (field, message) tuples, one for each problem detected. field can be None to indicate an overall problem with the page. Therefore, a return value of [] means everything is OK. |
Then, the Wiki syntax itself can be extended. The first and less intrusive way is to provide new Wiki macros or Wiki processors. Those are basically the same thing, as they’re implemented using the following interface. The difference comes from the invocation syntax used in the Wiki markup, which manifests itself in the args parameter of IWikiMacroProvider.expand_macro().
Augment the Wiki markup with new Wiki macros.
Changed in version 0.12: new Wiki processors can also be added that way.
See also WikiMacroBase and wiki/WikiMacros#DevelopingCustomMacros and trac.wiki.api.IWikiMacroProvider extension point.
Called by the formatter when rendering the parsed wiki text.
New in version 0.11: This form is preferred over render_macro, as you get the formatter, which knows the current context (and the req, but ideally you shouldn’t use it in your macros).
Changed in version 0.12: added the args parameter
Parameters: |
|
---|
Return a tuple of a domain name to translate and plain text description of the macro or only the description with the specified name.
Changed in version 1.0: get_macro_description can return a domain to translate the description.
Return an iterable that provides the names of the provided macros.
Return True if the content generated is an inline XHTML element.
New in version 1.0.
Return the HTML output of the macro :deprecated:
The Wiki syntax can also be extended by introducing new markup.
Enrich the Wiki syntax with new markup.
See also wiki:TracDev/IWikiSyntaxProviderExample and trac.wiki.api.IWikiSyntaxProvider extension point.
Return an iterable over (namespace, formatter) tuples.
Each formatter should be a function of the form:
def format(formatter, ns, target, label, fullmatch=None):
pass
and should return some HTML fragment. The label is already HTML escaped, whereas the target is not. The fullmatch argument is optional, and is bound to the regexp match object for the link.
Return an iterable that provides additional wiki syntax.
Additional wiki syntax correspond to a pair of (regexp, cb), the regexp for the additional syntax and the callback cb which will be called if there’s a match. That function is of the form cb(formatter, ns, match).
The wiki system provide an access to all the pages.
Wiki system manager.
List of components that implement IWikiChangeListener
Iterate over the names of existing Wiki pages.
Parameters: | prefix – if given, only names that start with that prefix are included. |
---|
Whether a page with the specified name exists.
Enable/disable highlighting CamelCase links to missing pages (‘’since 0.9’‘).
List of components that implement IWikiMacroProvider
Create a label from a wiki target.
A trailing fragment and query string is stripped. Then, leading ./, ../ and / elements are stripped, except when this would lead to an empty label. Finally, if split_page_names is true, the label is split accordingly.
Return the names of all existing wiki pages.
Enable/disable the use of unsafe HTML tags such as <script> or <embed> with the HTML [wiki:WikiProcessors WikiProcessor] (‘’since 0.10.4’‘).
For public sites where anonymous users can edit the wiki it is recommended to leave this option disabled (which is the default).
List of URI schemes considered “safe”, that will be rendered as external links even if [wiki] render_unsafe_content is false. (‘’since 0.11.8’‘)
Enable/disable splitting the WikiPageNames with space characters (‘’since 0.10’‘).
List of components that implement IWikiSyntaxProvider
Utility for parsing macro “content” and splitting them into arguments.
The content is split along commas, unless they are escaped with a backquote (see example below).
Parameters: |
|
---|
Example usage:
>>> parse_args('')
([], {})
>>> parse_args('Some text')
(['Some text'], {})
>>> parse_args('Some text, mode= 3, some other arg\, with a comma.')
(['Some text', ' some other arg, with a comma.'], {'mode': ' 3'})
>>> parse_args('milestone=milestone1,status!=closed', strict=False)
([], {'status!': 'closed', 'milestone': 'milestone1'})
Utility for validating wiki page name.
Parameters: | pagename – wiki page name to validate |
---|