Processors are WikiMacros designed to provide alternative markup formats for the Wiki engine. 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:
To use a processor on a block of text, first delimit the lines using a Wiki code block:
{{{ The lines that should be processed... }}}
Immediately after the {{{
or on the line just below,
add #!
followed by the processor name.
{{{ #!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.
Wiki Markup | Display |
---|---|
| |
{{{ <h1 style="color: grey">This is raw HTML</h1> }}} | This is raw HTML |
| |
{{{#!div style="background: #ffd; border: 3px ridge" This is an example of embedded "code" block: {{{ #!python def hello(): return "world" }}} }}} | This is an example of embedded "code" block: def hello(): return "world" |
| |
{{{ #!html <form action="/query" method="get"><div> <input type="text" name="keywords" value="~" size="30"/> <input type="submit" value="Search by Keywords"/> <!-- To control what fields show up use hidden fields <input type="hidden" name="col" value="id"/> <input type="hidden" name="col" value="summary"/> <input type="hidden" name="col" value="status"/> <input type="hidden" name="col" value="milestone"/> <input type="hidden" name="col" value="version"/> <input type="hidden" name="col" value="owner"/> <input type="hidden" name="col" value="priority"/> <input type="hidden" name="col" value="component"/> --> </div></form> }}} |
The following processors are included in the Trac distribution:
#!default
#!
)
#!comment
#!html
#!htmlcomment
Note that #!html
blocks 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 the following processors for achieving a similar effect.
#!div
#!span
#!td
#!th
#!tr
#!td
and #!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.
#!rst
#!textile
Trac includes processors to provide inline syntax highlighting:
#!c
(C),#!cpp
(C++),#!python
(Python),#!perl
(Perl),#!ruby
(Ruby),#!php
(PHP),#!asp
(ASP),#!java
(Java),#!js
(Javascript),#!sql (SQL)
,#!xml
(XML or HTML),#!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:
{{{ #!text/html <h1>text</h1> }}}
The result will be syntax highlighted HTML code:
<h1>text</h1>
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 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