Trac - Wiki Processors - Wiki处理器

Trac - Wiki Processors - Wiki处理器

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:

  • html -- Insert custom HTML in a wiki page. See WikiHtml.
  • rst -- Trac support for Restructured Text. See WikiRestructuredText.
  • textile -- Supported if Textile is installed. See a Textile reference.
  • comment -- Do not process the text in this section (i.e. contents exist only in the plain text - not in the rendered page).

Textile link above is rotten. this one works, allows to test example. To install, download from http://cheeseshop.python.org/pypi/textile and run python setup.py install.

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
  • sh -- Bourne/Bash shell

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

[Wiki处理器文档地址]

http://trac.edgewall.org/wiki/WikiProcessors

[Trac官方网站]

http://trac.edgewall.org/

[Trac关键词]

Trac

[Trac相关论坛]

http://groups.google.com/group/trac-announce
http://groups.google.com/group/trac-dev
http://groups.google.com/group/trac-tickets
http://groups.google.com/group/trac-users
http://softeng.board.newsmth.net/

[Trac的源代码svn下载地址]

http://svn.edgewall.com/repos/trac

[Trac基础知识]

Trac源代码格式化,http://trac.edgewall.org/wiki/WikiProcessors

Trac中生成链接的格式,http://trac.edgewall.org/wiki/TracLinks

Trac的数据结构, http://trac.edgewall.org/wiki/TracDev/DatabaseSchema

Trac - 创建自定义报表,http://trac.edgewall.org/wiki/TracReports#CreatingCustomReports

The Trac Ticket Workflow System - Trac Ticket工作流系统, http://trac.edgewall.org/wiki/TracWorkflow

[Trac常见问题]

Trac导出的csv格式文件在Excel中处理unix时间戳

Trac中通过URL的querystring设置新ticket的默认属性

Trac中browser定位文件行数

Trac中wiki恢复历史版本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值