WikiProcessors (diff) - Xwrits - Trac

Changes from Version 1 of WikiProcessors

Show
Ignore:
Author:
trac (IP: 127.0.0.1)
Timestamp:
10/30/06 19:35:43 (9 months ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiProcessors

    vv1 
     1= Wiki Processors = 
     2Processors are WikiMacros designed to provide alternative markup formats for the Trac Wiki engine. Processors can be thought of as ''macro functions to process user-edited text''.  
     3 
     4The wiki engine uses processors to allow using [wiki:WikiRestructuredText Restructured Text] and [wiki:WikiHtml raw HTML] in any wiki text throughout Trac. 
     5 
     6== Using Processors == 
     7To use a processor on a block of text, use a wiki blockquote, selecting a processor by name using ''shebang notation'' (#!), familiar to most UNIX users from scripts. 
     8 
     9'''Example 1''' (''inserting raw HTML in a wiki text''): 
     10 
     11{{{ 
     12#!html 
     13<pre class="wiki">{{{ 
     14#!html 
     15&lt;h1 style="color: orange"&gt;This is raw HTML&lt;/h1&gt; 
     16}}}</pre> 
     17}}} 
     18 
     19'''Results in:''' 
     20{{{ 
     21#!html 
     22<h1 style="color: orange">This is raw HTML</h1> 
     23}}} 
     24 
     25---- 
     26 
     27'''Example 2''' (''inserting Restructured Text in wiki text''): 
     28 
     29{{{ 
     30#!html 
     31<pre class="wiki">{{{ 
     32#!rst 
     33A header 
     34-------- 
     35This is some **text** with a footnote [*]_. 
     36 
     37.. [*] This is the footnote. 
     38}}}</pre> 
     39}}} 
     40 
     41'''Results in:''' 
     42{{{ 
     43#!rst 
     44A header 
     45-------- 
     46This is some **text** with a footnote [*]_. 
     47 
     48.. [*] This is the footnote. 
     49}}} 
     50---- 
     51'''Example 3''' (''inserting a block of C source code in wiki text''): 
     52 
     53{{{ 
     54#!html 
     55<pre class="wiki">{{{ 
     56#!c 
     57int main(int argc, char *argv[]) 
     58{ 
     59  printf("Hello World 
     60"); 
     61  return 0; 
     62} 
     63}}}</pre> 
     64}}} 
     65 
     66'''Results in:''' 
     67{{{ 
     68#!c 
     69int main(int argc, char *argv[]) 
     70{ 
     71  printf("Hello World 
     72"); 
     73  return 0; 
     74} 
     75}}} 
     76 
     77---- 
     78 
     79== Available Processors == 
     80The following processors are included in the Trac distribution: 
     81 * '''html''' -- Insert custom HTML in a wiki page. See WikiHtml. 
     82 * '''rst''' -- Trac support for Restructured Text. See WikiRestructuredText. 
     83 * '''textile''' -- Supported if  [http://dealmeida.net/projects/textile/ Textile] is installed. 
     84 
     85=== Code Highlighting Support === 
     86Trac includes processors to provide inline [wiki:TracSyntaxColoring syntax highlighting] for the following languages: 
     87 * '''c''' -- C 
     88 * '''cpp''' -- C++ 
     89 * '''python''' -- Python 
     90 * '''perl''' -- Perl 
     91 * '''ruby''' -- Ruby 
     92 * '''php''' -- PHP 
     93 * '''asp''' --- ASP 
     94 * '''sql''' -- SQL 
     95 * '''xml''' -- XML 
     96'''Note:''' ''Trac relies on external software packages for syntax coloring. See TracSyntaxColoring for more info.'' 
     97 
     98By 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: 
     99{{{ 
     100{{{ 
     101#!text/html 
     102<h1>text</h1> 
     103}}} 
     104}}} 
     105 
     106The result will be syntax highlighted HTML code. The same is valid for all other mime types supported. 
     107 
     108 
     109For more processor macros developed and/or contributed by users, visit:  
     110 * [http://projects.edgewall.com/trac/wiki/ProcessorBazaar ProcessorBazaar] 
     111 * [http://projects.edgewall.com/trac/wiki/MacroBazaar MacroBazaar] 
     112 
     113 
     114== Advanced Topics: Developing Processor Macros == 
     115Developing processors is no different than WikiMacros. In fact they work the same way, only the usage syntax differs. See WikiMacros for more information. 
     116 
     117'''Example:''' (''Restructured Text Processor''): 
     118{{{ 
     119from docutils.core import publish_string 
     120 
     121def execute(hdf, text, env): 
     122    html = publish_string(text, writer_name = 'html') 
     123    return html[html.find('<body>')+6:html.find('</body>')].strip() 
     124}}} 
     125 
     126---- 
     127See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide