ˆà | 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ˆà |