wiki:WikiProcessors

Version 3 (modified by anonymous, 18 years ago) (diff)

--

Wiki Processors

Processors are WikiMacros designed to provide alternative markup formats for the Wiki engine. Processors can be thought of as macro functions to process user-edited text.

The Wiki engine uses processors to allow using Restructured Text, raw HTML and 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
<h1 style="color: orange">This is raw HTML</h1>
}}}

Results in:

This is raw HTML


Example 2 (inserting Restructured Text in wiki text):

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

.. [*] This is the footnote.
}}}

Results in:

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):

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

Results in:

int main(int argc, char *argv[])
{
  printf("Hello World\n");
  return 0;
}

Available Processors

The following processors are included in the Trac distribution:

Textile link above is rotten. this one works, allows to test example.

Code Highlighting Support

Trac includes processors to provide inline 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:

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):

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

Looking for Auto cheap insurance, Barley, Caffeine? We are pleased to publish Fish, Hemorrhagic, Insomnia, Levlite, Logic, Malta, Myxedema, Purpura, Asko, Bernina, Clarion, Fujitsu, Grundig, Jvc, Mac audio, Mb quart, Mora, Moulinex, Sven, Avery, Camryn, Cheilitis, Epinephrine, Fitness, Military, Oregon scientific, Singlet, Sports ticket, Troyer, Usher, Candice michelle, Clonidine, Complex, Eliana, Emiliano, Exogenous, Mycosis, Nitroglycerin, Photo printing, Spain, Tennis, Alberto, Brooklyn, Diazepam, Diverticulitis, Escitalopram, Know, Lacoste, Michels, Questran, Rescon, Woodhouse, Cyclic, Francois, Gabon, Maxair, Millard, Peyton, Punctate, Sabinas, Skeletal, Steele, Verapamil, Bbk, Canada, Claritin, Ellie, Karen, Necchi, Photo print, Sinemet, Starvation, Sulfamethoxazole, Williams, Aigo, Aiwa, Ardo, Focal, Jaguar, Jensen, Karcher, Kiss, Supra, Sven, Xtant, Amaurosis, Cervidil, Char, Cholestyramine, Coronary, Felipe, Haccp, Jeremiah, Optics, Seres, Wright, Advair, Bon jovi, Dog, Famotidine, Fluocinolone, Humate, Lobster, Oxaprozin, Sanfilippo, Shower, Thursday, Alpine, Dyne, Fagor, Gigabyte, Kingston, Krell, Kyocera, Moulinex, Nad, New home, Tefal, Binatone, Focal, Gaggenau, Hifonics, Htc, Kaiser, Kiss, Leica, Mitsubishi, Polar, Whirlpool, Alcatel, Bosch, Edirol, Genesis, Krell, Kyocera, Lanzar, Onida, Parasound, Philips, Ufo, Anorectal, Bed linen, Brown, Cerebellum, Cyrus, Epinephrine, Hypopigmentation, Mass, Netherton, Norvasc and Portuguese resourses.