= Wiki Processors =

Processors are WikiMacros designed to provide alternative markup formats for the [TracWiki Wiki engine]. Processors can be thought of as ''macro functions to process user-edited text''.

The Wiki engine uses processors to allow using [wiki:WikiRestructuredText Restructured Text], [wiki:WikiHtml raw HTML] and [http://www.textism.com/tools/textile/ textile] in any Wiki text throughout Trac.

== Using Processors ==

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">{{{ #!html <h1 style="color: orange">This is raw HTML</h1> }}}</pre> }}}

'''Results in:''' {{{ #!html <h1 style="color: orange">This is raw HTML</h1> }}}


'''Example 2''' (''inserting Restructured Text in wiki text''):

{{{ #!html <pre class="wiki">{{{ #!rst A header -------- This is some text with a footnote [*].

[*]This is the footnote.

System Message: WARNING/2 (<string>, line 41)

Explicit markup ends without a blank line; unexpected unindent.

}}}</pre> }}}

'''Results in:''' {{{ #!rst A header -------- This is some text with a footnote [†].

[†]This is the footnote.

System Message: WARNING/2 (<string>, line 52)

Explicit markup ends without a blank line; unexpected unindent.

}}}

'''Example 3''' (''inserting a block of C source code in wiki text''):

{{{ #!html <pre class="wiki">{{{ #!c int main(int argc, char *argv[]) {

System Message: WARNING/2 (<string>, line 56); backlink

Inline emphasis start-string without end-string.

System Message: ERROR/3 (<string>, line 62)

Unexpected indentation.
printf("Hello World

System Message: WARNING/2 (<string>, line 63)

Block quote ends without a blank line; unexpected unindent.
");
return 0;

System Message: WARNING/2 (<string>, line 65)

Definition list ends without a blank line; unexpected unindent.

} }}}</pre> }}}

'''Results in:''' {{{ #!c int main(int argc, char *argv[]) {

System Message: WARNING/2 (<string>, line 69); backlink

Inline emphasis start-string without end-string.

System Message: ERROR/3 (<string>, line 74)

Unexpected indentation.
printf("Hello World

System Message: WARNING/2 (<string>, line 75)

Block quote ends without a blank line; unexpected unindent.
");
return 0;

System Message: WARNING/2 (<string>, line 77)

Definition list ends without a blank line; unexpected unindent.

}

System Message: ERROR/3 (<string>, line 80)

Document or section may not begin with a transition.

== Available Processors == The following processors are included in the Trac distribution:

System Message: ERROR/3 (<string>, line 84)

Unexpected indentation.

Textile link above is rotten. [http://www.textism.com/tools/textile/ this one] works, allows to test example.

Trac includes processors to provide inline [wiki:TracSyntaxColoring syntax highlighting] for the following languages:

System Message: ERROR/3 (<string>, line 92)

Unexpected indentation.
  • '''c''' -- C
  • '''cpp''' -- C++
  • '''python''' -- Python
  • '''perl''' -- Perl
  • '''ruby''' -- Ruby
  • '''php''' -- PHP
  • '''asp''' --- ASP
  • '''sql''' -- SQL
  • '''xml''' -- XML

Note

See TracSyntaxColoring for more info.

By using the MIME type as processor, it is possible to syntax-highlight the same languages that are supported when browsing source code. For example, you can write:

The result will be syntax highlighted HTML code. The same is valid for all other mime types supported.

For more processor macros developed and/or contributed by users, visit:

Developing processors is no different from WikiMacros. In fact they work the same way, only the usage syntax differs. See WikiMacros for more information.

'''Example:''' (''Restructured Text Processor''):

from docutils.core import publish_string
def execute(hdf, text, env):
  html = publish_string(text, writer_name = 'html')
  return html[html.find('<body>')+6:html.find('</body>')].strip()

See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide

Return to the FrontPage | Edit WikiProcessors | Title List