File: WikiProcessors

package info (click to toggle)
trac 0.10.3-1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,692 kB
  • ctags: 2,972
  • sloc: python: 22,683; cs: 3,174; sh: 30; makefile: 10
file content (131 lines) | stat: -rw-r--r-- 3,710 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
= Wiki Processors =

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''. 

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.


== Using Processors ==

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.

'''Example 1''' (''inserting raw HTML in a wiki text''):

{{{
#!html
<pre class="wiki">{{{
#!html
&lt;h1 style="color: orange"&gt;This is raw HTML&lt;/h1&gt;
}}}</pre>
}}}

'''Results in:'''
{{{
#!html
<h1 style="color: orange">This is raw HTML</h1>
}}}

----

'''Example 2''' (''inserting Restructured Text in wiki text''):

{{{
#!html
<pre class="wiki">{{{
#!rst
A header
--------
This is some **text** with a footnote [*]_.

.. [*] This is the footnote.
}}}</pre>
}}}

'''Results in:'''
{{{
#!rst
A header
--------
This is some **text** with a footnote [*]_.

.. [*] This is the footnote.
}}}
----
'''Example 3''' (''inserting a block of C source code in wiki text''):

{{{
#!html
<pre class="wiki">{{{
#!c
int main(int argc, char *argv[])
{
  printf("Hello World\n");
  return 0;
}
}}}</pre>
}}}

'''Results in:'''
{{{
#!c
int main(int argc, char *argv[])
{
  printf("Hello World\n");
  return 0;
}
}}}

----

== Available Processors ==
The following processors are included in the Trac distribution:
 * '''html''' -- Insert custom HTML in a wiki page. See WikiHtml.
 * '''rst''' -- Trac support for Restructured Text. See WikiRestructuredText.
 * '''textile''' -- Supported if  [http://dealmeida.net/projects/textile/ Textile] is installed. See [http://hobix.com/textile/ a Textile reference].

Textile link above is rotten. [http://www.textism.com/tools/textile/ this one] works, allows to test example.

=== Code Highlighting Support ===
Trac includes processors to provide inline [wiki:TracSyntaxColoring syntax highlighting] for the following languages:
 * '''c''' -- C
 * '''cpp''' -- C++
 * '''python''' -- Python
 * '''perl''' -- Perl
 * '''ruby''' -- Ruby
 * '''php''' -- PHP
 * '''asp''' --- ASP
 * '''sql''' -- SQL
 * '''xml''' -- XML
'''Note:''' ''Trac relies on external software packages for syntax coloring. See TracSyntaxColoring for more info.''

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. The same is valid for all other mime types supported.


For more processor macros developed and/or contributed by users, visit: 
 * [http://projects.edgewall.com/trac/wiki/ProcessorBazaar ProcessorBazaar]
 * [http://projects.edgewall.com/trac/wiki/MacroBazaar MacroBazaar]


== Advanced Topics: Developing Processor Macros ==
Developing processors is no different from WikiMacros. In fact they work the same way, only the usage syntax differs. See WikiMacros for more information.

'''Example:''' (''Restructured Text Processor''):
{{{
#!python
from docutils.core import publish_string

def execute(hdf, text, env):
    html = publish_string(text, writer_name = 'html')
    return html[html.find('<body>')+6:html.find('</body>')].strip()
}}}

----
See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide