|   | 1 | = Wiki Processors =  | 
                  
                          |   | 2 |   | 
                  
                          |   | 3 | 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''.   | 
                  
                          |   | 4 |   | 
                  
                          |   | 5 | 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.  | 
                  
                          |   | 6 |   | 
                  
                          |   | 7 |   | 
                  
                          |   | 8 | == Using Processors ==  | 
                  
                          |   | 9 |   | 
                  
                          |   | 10 | 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.  | 
                  
                          |   | 11 |   | 
                  
                          |   | 12 | '''Example 1''' (''inserting raw HTML in a wiki text''):  | 
                  
                          |   | 13 |   | 
                  
                          |   | 14 | {{{  | 
                  
                          |   | 15 | #!html  | 
                  
                          |   | 16 | <pre class="wiki">{{{  | 
                  
                          |   | 17 | #!html  | 
                  
                          |   | 18 | <h1 style="color: orange">This is raw HTML</h1>  | 
                  
                          |   | 19 | }}}</pre>  | 
                  
                          |   | 20 | }}}  | 
                  
                          |   | 21 |   | 
                  
                          |   | 22 | '''Results in:'''  | 
                  
                          |   | 23 | {{{  | 
                  
                          |   | 24 | #!html  | 
                  
                          |   | 25 | <h1 style="color: orange">This is raw HTML</h1>  | 
                  
                          |   | 26 | }}}  | 
                  
                          |   | 27 |   | 
                  
                          |   | 28 | 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).  | 
                  
                          |   | 29 |   | 
                  
                          |   | 30 | ----  | 
                  
                          |   | 31 |   | 
                  
                          |   | 32 | '''Example 2''' (''inserting Restructured Text in wiki text''):  | 
                  
                          |   | 33 |   | 
                  
                          |   | 34 | {{{  | 
                  
                          |   | 35 | #!html  | 
                  
                          |   | 36 | <pre class="wiki">{{{  | 
                  
                          |   | 37 | #!rst  | 
                  
                          |   | 38 | A header  | 
                  
                          |   | 39 | --------  | 
                  
                          |   | 40 | This is some **text** with a footnote [*]_.  | 
                  
                          |   | 41 |   | 
                  
                          |   | 42 | .. [*] This is the footnote.  | 
                  
                          |   | 43 | }}}</pre>  | 
                  
                          |   | 44 | }}}  | 
                  
                          |   | 45 |   | 
                  
                          |   | 46 | '''Results in:'''  | 
                  
                          |   | 47 | {{{  | 
                  
                          |   | 48 | #!rst  | 
                  
                          |   | 49 | A header  | 
                  
                          |   | 50 | --------  | 
                  
                          |   | 51 | This is some **text** with a footnote [*]_.  | 
                  
                          |   | 52 |   | 
                  
                          |   | 53 | .. [*] This is the footnote.  | 
                  
                          |   | 54 | }}}  | 
                  
                          |   | 55 | ----  | 
                  
                          |   | 56 | '''Example 3''' (''inserting a block of C source code in wiki text''):  | 
                  
                          |   | 57 |   | 
                  
                          |   | 58 | {{{  | 
                  
                          |   | 59 | #!html  | 
                  
                          |   | 60 | <pre class="wiki">{{{  | 
                  
                          |   | 61 | #!c  | 
                  
                          |   | 62 | int main(int argc, char *argv[])  | 
                  
                          |   | 63 | {  | 
                  
                          |   | 64 |   printf("Hello World\n");  | 
                  
                          |   | 65 |   return 0;  | 
                  
                          |   | 66 | }  | 
                  
                          |   | 67 | }}}</pre>  | 
                  
                          |   | 68 | }}}  | 
                  
                          |   | 69 |   | 
                  
                          |   | 70 | '''Results in:'''  | 
                  
                          |   | 71 | {{{  | 
                  
                          |   | 72 | #!c  | 
                  
                          |   | 73 | int main(int argc, char *argv[])  | 
                  
                          |   | 74 | {  | 
                  
                          |   | 75 |   printf("Hello World\n");  | 
                  
                          |   | 76 |   return 0;  | 
                  
                          |   | 77 | }  | 
                  
                          |   | 78 | }}}  | 
                  
                          |   | 79 |   | 
                  
                          |   | 80 | ----  | 
                  
                          |   | 81 |   | 
                  
                          |   | 82 | == Available Processors ==  | 
                  
                          |   | 83 | The following processors are included in the Trac distribution:  | 
                  
                          |   | 84 |  * '''html''' -- Insert custom HTML in a wiki page. See WikiHtml.  | 
                  
                          |   | 85 |  * '''div''' -- Wrap an arbitrary Wiki content in a <div> element (''since 0.11''). See WikiHtml.  | 
                  
                          |   | 86 |  * '''span''' -- Wrap an arbitrary Wiki content in a <span> element (''since 0.11''). See also WikiHtml.  | 
                  
                          |   | 87 |  * '''rst''' -- Trac support for Restructured Text. See WikiRestructuredText.  | 
                  
                          |   | 88 |  * '''textile''' -- Supported if [http://cheeseshop.python.org/pypi/textile Textile] is installed. See [http://www.textism.com/tools/textile/ a Textile reference].  | 
                  
                          |   | 89 |  * '''comment''' -- Do not process the text in this section (i.e. contents exist only in the plain text - not in the rendered page).  | 
                  
                          |   | 90 |  * '''diff''' -- Pretty print patches and diffs.  | 
                  
                          |   | 91 |   | 
                  
                          |   | 92 | === Code Highlighting Support ===  | 
                  
                          |   | 93 | Trac includes processors to provide inline [wiki:TracSyntaxColoring syntax highlighting] for the following languages:  | 
                  
                          |   | 94 |  * '''c''' -- C  | 
                  
                          |   | 95 |  * '''cpp''' -- C++  | 
                  
                          |   | 96 |  * '''csharp''' --- C# (''use #!text/x-csharp'')  | 
                  
                          |   | 97 |  * '''python''' -- Python  | 
                  
                          |   | 98 |  * '''perl''' -- Perl  | 
                  
                          |   | 99 |  * '''ruby''' -- Ruby  | 
                  
                          |   | 100 |  * '''php''' -- PHP  | 
                  
                          |   | 101 |  * '''asp''' -- ASP  | 
                  
                          |   | 102 |  * '''java''' -- Java  | 
                  
                          |   | 103 |  * '''js''' -- Javascript  | 
                  
                          |   | 104 |  * '''sql''' -- SQL  | 
                  
                          |   | 105 |  * '''xml''' -- XML  | 
                  
                          |   | 106 |  * '''sh''' -- Bourne/Bash shell  | 
                  
                          |   | 107 |   | 
                  
                          |   | 108 | '''Note:''' ''Trac relies on external software packages for syntax coloring. See TracSyntaxColoring for more info.''  | 
                  
                          |   | 109 |   | 
                  
                          |   | 110 | 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:  | 
                  
                          |   | 111 | {{{  | 
                  
                          |   | 112 | {{{  | 
                  
                          |   | 113 | #!text/html  | 
                  
                          |   | 114 | <h1>text</h1>  | 
                  
                          |   | 115 | }}}  | 
                  
                          |   | 116 | }}}  | 
                  
                          |   | 117 |   | 
                  
                          |   | 118 | The result will be syntax highlighted HTML code:  | 
                  
                          |   | 119 | {{{  | 
                  
                          |   | 120 | #!text/html  | 
                  
                          |   | 121 | <h1>text</h1>  | 
                  
                          |   | 122 | }}}  | 
                  
                          |   | 123 |   | 
                  
                          |   | 124 | The same is valid for all other mime types supported.  | 
                  
                          |   | 125 |   | 
                  
                          |   | 126 |   | 
                  
                          |   | 127 | For more processor macros developed and/or contributed by users, visit:   | 
                  
                          |   | 128 |  * [trac:ProcessorBazaar]  | 
                  
                          |   | 129 |  * [trac:MacroBazaar]  | 
                  
                          |   | 130 |  * [th:WikiStart Trac Hacks] community site  | 
                  
                          |   | 131 |   | 
                  
                          |   | 132 |   | 
                  
                          |   | 133 | == Advanced Topics: Developing Processor Macros ==  | 
                  
                          |   | 134 | 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.  | 
                  
                          |   | 135 |   | 
                  
                          |   | 136 |   | 
                  
                          |   | 137 | ----  | 
                  
                          |   | 138 | See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide  |