User Tools

Site Tools


wikiprocessors
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


wikiprocessors [2015/06/09 15:23] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== 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 [[WikiRestructuredText|Restructured Text]], [[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//):
 +
 +<code>
 +#!html
 +<pre class="wiki"><code>
 +#!html
 +&lt;h1 style="color: orange"&gt;This is raw HTML&lt;/h1&gt;
 +</code>
 +</pre>
 +</code>
 +
 +
 +**Results in:**
 +<code>
 +#!html
 +<h1 style="color: orange">This is raw HTML</h1>
 +</code>
 +
 +
 +----
 +
 +**Example 2** (//inserting Restructured Text in wiki text//):
 +
 +<code>
 +#!html
 +<pre class="wiki"><code>
 +#!rst
 +A header
 +--------
 +This is some **text** with a footnote [[:*]]_.
 +
 +.. [[:*]] This is the footnote.
 +</code>
 +</pre>
 +</code>
 +
 +
 +**Results in:**
 +<code>
 +#!rst
 +A header
 +--------
 +This is some **text** with a footnote [[:*]]_.
 +
 +.. [[:*]] This is the footnote.
 +</code>
 +
 +----
 +**Example 3** (//inserting a block of C source code in wiki text//):
 +
 +<code>
 +#!html
 +<pre class="wiki"><code>
 +#!c
 +int main(int argc, char *argv[])
 +{
 +  printf("Hello World\n");
 +  return 0;
 +}
 +</code>
 +</pre>
 +</code>
 +
 +
 +**Results in:**
 +<code>
 +#!c
 +int main(int argc, char *argv[])
 +{
 +  printf("Hello World\n");
 +  return 0;
 +}
 +</code>
 +
 +
 +----
 +
 +===== 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 [[: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:
 +<code>
 +<code>
 +#!text/html
 +<h1>text</h1>
 +</code>
 +
 +</code>
 +
 +
 +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//):
 +<code>
 +#!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()
 +</code>
 +
 +
 +----
 +See also: WikiMacros, WikiHtml, WikiRestructuredText, TracSyntaxColoring, WikiFormatting, TracGuide
  
wikiprocessors.txt · Last modified: 2015/06/09 15:23 by 127.0.0.1