Skip to content
trac edited this page Dec 4, 2011 · 2 revisions

Table of Contents

Wiki Processors

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.

Wiki processors can be used in any Wiki text throughout Trac, for various different purposes, like:

 - [#CodeHighlightingSupport syntax highlighting] or for rendering text verbatim,
 - rendering [#HTMLrelated Wiki markup inside a context], 
   like inside <div> blocks or <span> or within <td> or <th> table cells,
 - using an alternative markup syntax, like [[WikiHtml| raw HTML]] and
   [[WikiRestructuredText| Restructured Text]],
   or [http://www.textism.com/tools/textile/ textile]

Using Processors

To use a processor on a block of text, first delimit the lines using a Wiki code block:

<pre>
The lines
that should be processed...

Immediately after the <pre> or on the line just below, add #! followed by the processor name.

<pre>
#processorname
The lines
that should be processed...

This is the "shebang" notation, familiar to most UNIX users.

Besides their content, some Wiki processors can also accept parameters, which are then given as key=value pairs after the processor name, on the same line. If value has to contain space, as it's often the case for the style parameter, a quoted string can be used (key="value with space").

As some processors are meant to process Wiki markup, it's quite possible to nest processor blocks. You may want to indent the content of nested blocks for increased clarity, this extra indentation will be ignored when processing the content.

Examples

Wiki Markup

Display

                <u>Example 1</u>: Inserting raw HTML
|-----------------------------------------------------------------
#td style="border: none"
<pre>
<pre>
<h1 style="color: grey">This is raw HTML</h1>
#td valign=top style="border: none; padding-left: 2em"
<pre>
#html
<h1 style="color: grey">This is raw HTML</h1>
|-----------------------------------------------------------------
     <u>Example 2</u>: Highlighted Python code in a <div> block with custom style
|-----------------------------------------------------------------
  This is an example of embedded "code" block:

    <pre>
    #python
    def hello():
        return "world"
    
  
  This is an example of embedded "code" block:

    <pre>
    #python
    def hello():
        return "world"
    

|-----------------------------------------------------------------

     <u>Example 3</u>: Searching tickets from a wiki page, by keywords.
|-----------------------------------------------------------------
  </div></form>
  
  </div></form>
  

Available Processors

The following processors are included in the Trac distribution:

#default :: Present the text verbatim in a preformatted text block. This is the same as specifying no processor name (and no #!) #comment :: Do not process the text in this section (i.e. contents exist only in the plain text - not in the rendered page).

HTML related

#html :: Insert custom HTML in a wiki page. #htmlcomment :: Insert an HTML comment in a wiki page (since 0.12).

Note that #html blocks have to be self-contained,

  1. e. you can't start an HTML element in one block and close it later in a second block. Use the following processors for achieving a similar effect.
#div :: Wrap an arbitrary Wiki content inside a
element (since 0.11). &#35;span :: Wrap an arbitrary Wiki content inside a element (since 0.11).

&amp;&#35;35&#59;td :: Wrap an arbitrary Wiki content inside a

element (since 0.12) &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;th :: Wrap an arbitrary Wiki content inside a element (since 0.12) &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;tr :: Can optionally be used for wrapping &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;td and &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;th blocks, either for specifying row attributes of better visual grouping (since 0.12) See WikiHtml for example usage and more details about these processors.

Other Markups

&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;rst :: Trac support for Restructured Text. See WikiRestructuredText. &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;textile :: Supported if Textile is installed. See a Textile reference.

Code Highlighting Support

Trac includes processors to provide inline syntax highlighting: &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;c (C), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;cpp (C++), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;python (Python), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;perl (Perl), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;ruby (Ruby), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;php (PHP), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;asp (ASP), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;java (Java), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;js (Javascript), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;sql (SQL), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;xml (XML or HTML), &amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;sh (Bourne/Bash shell), etc. Trac relies on external software packages for syntax coloring, like Pygments. See TracSyntaxColoring for information about which languages are supported and how to enable support for more languages. Note also that 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:
&amp;amp&#59;lt&amp;&#35;59&#59;pre&amp;amp&#59;gt&amp;&#35;59&#59;
&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;text/html
&amp;amp&#59;lt&amp;&#35;59&#59;h1&amp;amp&#59;gt&amp;&#35;59&#59;text&amp;amp&#59;lt&amp;&#35;59&#59;/h1&amp;amp&#59;gt&amp;&#35;59&#59;
</pre>

The result will be syntax highlighted HTML code:

&amp;amp&#59;amp&amp;&#35;59&#59;&amp;amp&#59;&amp;&#35;35&#59;35&amp;&#35;59&#59;35&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;text/html
&amp;amp&#59;amp&amp;&#35;59&#59;lt&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;h1&amp;amp&#59;amp&amp;&#35;59&#59;gt&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;text&amp;amp&#59;amp&amp;&#35;59&#59;lt&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;/h1&amp;amp&#59;amp&amp;&#35;59&#59;gt&amp;amp&#59;&amp;&#35;35&#59;59&amp;&#35;59&#59;

The same is valid for all other [TracSyntaxColoring#SyntaxColoringSupport].

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#DevelopingCustomMacros for more information.
See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide
Clone this wiki locally