| 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 | * '''htmlcomment''' -- Insert an HTML comment in a wiki page (''since 0.12''). See WikiHtml. |
| 88 | * '''rst''' -- Trac support for Restructured Text. See WikiRestructuredText. |
| 89 | * '''textile''' -- Supported if [http://cheeseshop.python.org/pypi/textile Textile] is installed. See [http://www.textism.com/tools/textile/ a Textile reference]. |
| 90 | * '''comment''' -- Do not process the text in this section (i.e. contents exist only in the plain text - not in the rendered page). |
| 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 | * '''python''' -- Python |
| 97 | * '''perl''' -- Perl |
| 98 | * '''ruby''' -- Ruby |
| 99 | * '''php''' -- PHP |
| 100 | * '''asp''' -- ASP |
| 101 | * '''java''' -- Java |
| 102 | * '''js''' -- Javascript |
| 103 | * '''sql''' -- SQL |
| 104 | * '''xml''' -- XML |
| 105 | * '''sh''' -- Bourne/Bash shell |
| 106 | |
| 107 | '''Note:''' ''Trac relies on external software packages for syntax coloring. See TracSyntaxColoring for more info.'' |
| 108 | |
| 109 | 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: |
| 110 | {{{ |
| 111 | {{{ |
| 112 | #!text/html |
| 113 | <h1>text</h1> |
| 114 | }}} |
| 115 | }}} |
| 116 | |
| 117 | The result will be syntax highlighted HTML code: |
| 118 | {{{ |
| 119 | #!text/html |
| 120 | <h1>text</h1> |
| 121 | }}} |
| 122 | |
| 123 | The same is valid for all other mime types supported. |
| 124 | |
| 125 | |
| 126 | For more processor macros developed and/or contributed by users, visit: |
| 127 | * [trac:ProcessorBazaar] |
| 128 | * [trac:MacroBazaar] |
| 129 | * [th:WikiStart Trac Hacks] community site |
| 130 | |
| 131 | |
| 132 | == Advanced Topics: Developing Processor Macros == |
| 133 | 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. |
| 134 | |
| 135 | |
| 136 | ---- |
| 137 | See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide |