-
Notifications
You must be signed in to change notification settings - Fork 10
WikiProcessors
Processors are WikiMacros designed to provide alternative markup formats for the [TracWiki]. Processors can be thought of as macro functions to process user-edited text.
The Wiki engine uses processors to allow using Restructured Text, raw HTML and textile in any Wiki text throughout Trac.
To use a processor on a block of text, use a Wiki code block, selecting a processor by name using shebang notation (#!), familiar to most UNIX users from scripts.
Example 1 (inserting raw HTML in a wiki text):
#html <pre class="wiki"><pre> #html <h1 style="color: orange">This is raw HTML</h1>
Results in:
#html <h1 style="color: orange">This is raw HTML</h1>
Note that since 0.11, such blocks of HTML have to be self-contained, i.e. you can't start an HTML element in one block and close it later in a second block. Use div or span processors for achieving similar effect (see WikiHtml).
Example 2 (inserting Restructured Text in wiki text):
#html <pre class="wiki"><pre> #rst A header -------- This is some **text** with a footnote [*]_. .. [*] This is the footnote.
Results in:
#rst A header -------- This is some **text** with a footnote [*]_. .. [*] This is the footnote.
Example 3 (inserting a block of C source code in wiki text):
#html
<pre class="wiki"><pre>
#c
int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0;
}
Results in:
#c
int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0;
}
The following processors are included in the Trac distribution:
- html -- Insert custom HTML in a wiki page. See WikiHtml.
- div -- Wrap an arbitrary Wiki content in a element (since 0.11). See WikiHtml.
- span -- Wrap an arbitrary Wiki content in a element (since 0.11). See also WikiHtml.
- rst -- Trac support for Restructured Text. See WikiRestructuredText.
- textile -- Supported if Textile is installed. See a Textile reference.
- comment -- Do not process the text in this section (i.e. contents exist only in the plain text - not in the rendered page).
- c -- C
- cpp -- C++
- python -- Python
- perl -- Perl
- ruby -- Ruby
- php -- PHP
- asp -- ASP
- java -- Java
- js -- Javascript
- sql -- SQL
- xml -- XML
- sh -- Bourne/Bash shell
<pre> #text/html <h1>text</h1></pre>
The result will be syntax highlighted HTML code:
&#35;text/html &lt;h1&gt;text&lt;/h1&gt;
The same is valid for all other mime types supported.
For more processor macros developed and/or contributed by users, visit:
- [trac:ProcessorBazaar]
- [trac:MacroBazaar]
- [th:WikiStart] community site
Developing processors is no different from Wiki macros. In fact they work the same way, only the usage syntax differs. See WikiMacros for more information.
See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide