Home

Documentation

Project Support

Changes in Version 1 of WikiProcessors

Author:
trac
Timestamp:
Wed Aug 23 17:34:43 2006

Legend:

Unmodified
Added
Removed
Modified
  • WikiProcessors

    v0 v1
      1  = Wiki Processors = 
      2  Processors 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   
      4  The 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 == 
      7  To use a processor on a block of text, use a wiki blockquote, selecting a processor by name using 'hashbang 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 
      33  A header 
      34  -------- 
      35  This is some **text** with a footnote [*]_. 
      36   
      37  .. [*] This is the footnote. 
      38  }}}</pre> 
      39  }}} 
      40   
      41  '''Results in:''' 
      42  {{{ 
      43  #!rst 
      44  A header 
      45  -------- 
      46  This 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 
      57  int main(int argc, char *argv[]) 
      58  { 
      59    printf("Hello World\n"); 
      60    return 0; 
      61  } 
      62  }}}</pre> 
      63  }}} 
      64   
      65  '''Results in:''' 
      66  {{{ 
      67  #!c 
      68  int main(int argc, char *argv[]) 
      69  { 
      70    printf("Hello World\n"); 
      71    return 0; 
      72  } 
      73  }}} 
      74   
      75  ---- 
      76   
      77   
      78   
      79  == Available Processors == 
      80  The 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''' -- Initial support as of aug 2, 2004.  See [http://projects.edgewall.com/trac/ticket/593 ticket 593] and [http://dealmeida.net/projects/textile/ Textile]. 
      84   
      85  === Source Code Support === 
      86  Trac includes processors to provide inline [wiki:TracSyntaxColoring syntax highlighting] for these 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   
      98  By using the mime-type as processor, it is posible to syntax-highlight the same languages that are supported when browsing source code.  (The list of mime-types can be found in [source:trunk/trac/Mimeview.py Mimeview.py]). 
      99   
      100  For example, you can write: 
      101   
      102  {{{ 
      103  {{{ 
      104  #!text/html 
      105  <h1>text</h1> 
      106  }}} 
      107  }}} 
      108   
      109  The result will be syntax highlighted html code. The same is valid for all other mime types supported. 
      110   
      111   
      112   
      113  For more processor macros developed and/or contributed by users, visit the macro bazaar:  
      114   http://projects.edgewall.com/trac/wiki/MacroBazaar 
      115   
      116  ---- 
      117  == Advanced Topics: Developing Processor Macros == 
      118  Developing processors is no different than WikiMacros. In fact they work the same way, only the usage syntax differs. See WikiMacros for more information. 
      119   
      120  '''Example:''' (''Restructured Text Processor''): 
      121  {{{ 
      122  from docutils.core import publish_string 
      123   
      124  def execute(hdf, text, env): 
      125      html = publish_string(text, writer_name = 'html') 
      126      return html[html.find('<body>')+6:html.find('</body>')].strip() 
      127  }}} 
      128   
      129  ---- 
      130  See also : WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide