wiki 显示html,WikiHtml

本文档详细介绍了Trac Wiki中HTML和表格的使用,包括#!html、#!div、#!span、#!table等处理器的用法。Trac支持在Wiki文本中插入HTML,但会过滤掉潜在的危险构造,如JavaScript事件处理器。对于创建样式和复杂表格,#!div、#!span和#!table等处理器提供了强大的替代方案。此外,还详细说明了如何通过指定不同的CSS类来调整元素的样式和布局。
摘要由CSDN通过智能技术生成

This page documents the 1.4 (latest stable) release.

Documentation for other releases can be found

here.

Using HTML in Wiki Text

Trac supports the display of HTML in any wiki context, by using the #!html WikiProcessor.

However, this HTML has to be ​well-formed.

In particular, you can't insert a start tag in an #!html block, resume normal wiki text and insert the corresponding end tag in a second #!html block.

For creating styled

s, s or even complex tables containing arbitrary Wiki text, there is a powerful alternative: #!div, #!span and #!table, #!tr, #!td and #!th blocks. Those Wiki processors are built-in and do not require additional packages to be installed.

How to use #!html

To inform the wiki engine that a block of text should be treated as HTML, use the html processor:

Wiki MarkupDisplay

{{{#!html

HTML Test

}}}HTML Test

Note that Trac sanitizes your HTML code before displaying it. That means that potentially dangerous constructs, such as Javascript event handlers, will be removed from the output.

The filtering is done by ​Genshi and the output will be a well-formed fragment of HTML. This means that you cannot use two HTML blocks, one for opening a

and another for closing it, in order to wrap arbitrary wiki text.

How to use #!div and #!span

Wiki MarkupDisplay

{{{#!div class="important"

**important** is a predefined class.

}}}{{{#!div style="border: 1pt dotted; margin: 1em"

**wikipage** is another predefined class that will

be used when no class is specified.

}}}{{{#!div class="compact" style="border: 1pt dotted; margin: 1em"

**compact** is another predefined class reducing

the padding within the `

` to a minimum.

}}}{{{#!div class="wikipage compact" style="border: 1pt dotted"

Classes can be combined (here **wikipage** and **compact**)

which results in this case in reduced //vertical//

padding but there's still some horizontal space for coping

with headings.

}}}{{{#!div class="" style="border: 1pt dotted; margin: 1em"

Explicitly specifying no classes is //not// the same

as specifying no class attribute, as this will remove

the //wikipage// default class.

}}}important is a predefined class.

wikipage is another predefined class that will

be used when no class is specified.

compact is another predefined class reducing

the padding within the

to a minimum.

Classes can be combined (here wikipage and compact)

which results in this case in reduced vertical

padding but there's still some horizontal space for coping

with headings.

Explicitly specifying no classes is not the same

as specifying no class attribute, as this will remove

the wikipage default class.

Note that the contents of a #!div block are contained in one or more paragraphs, which have a non-zero top and bottom margin. This leads to the top and bottom padding in the example above. To remove the top and bottom margin of the content, add the compact class to the #!div. Another predefined class besides wikipage and compact is important, which can be used to make a paragraph stand out. Extra CSS classes can be defined via site/style.css.

For spans, you should use the Macro call syntax:

Wiki Markup

Hello

[[span(''WORLD'' (click [#anchor here]), style=color: green; font-size: 120%, id=anchor)]]!

Display

Hello

WORLD (click here)!

How to use #!td and other table related processors

The #!td or #!th processors should be used to create table data and table header cells, respectively. The other processors #!table and #!tr are not required for introducing a table structure, as #!td and #!th will do this automatically. The |- row separator can be used to start a new row when needed, but some may prefer to use a #!tr block for that, as this introduces a more formal grouping and offers the possibility to use an extra level of indentation. The main purpose of the #!table and #!tr is to give the possibility to specify HTML attributes, like style or valign to these elements.

Wiki MarkupDisplay

Simple 2x2 table with rich content:

{{{#!th align=left

- Left

- Header

}}}

{{{#!th align=left

- Right

- Header

}}}

|----------------------------------

{{{#!td style="background: #ffd"

- Left

- Content

}}}

{{{#!td style="vertical-align: top"

!RightContent

}}}

|----------------------------------

|| ... and this can be mixed||\

||with pipe-based cells ||

{{{#!td colspan=2

Pick the style the more appropriate

to your content

See WikiFormatting#Tables for details

on the pipe-based table syntax.

}}}

If one needs to add some

attributes to the table itself...

{{{#!table style="border:none;text-align:center;margin:auto"

{{{#!tr ====================================

{{{#!th style="border: none"

Left header

}}}

{{{#!th style="border: none"

Right header

}}}

}}}

{{{#!tr ==== style="border: 1px dotted grey"

{{{#!td style="border: none"

1.1

}}}

{{{#!td style="border: none"

1.2

}}}

}}}

{{{#!tr ====================================

{{{#!td style="border: none"

2.1

}}}

{{{#!td

2.2

}}}

}}}

}}}Simple 2x2 table with rich content:

Left

HeaderRight

Header

Left

ContentRightContent

… and this can be mixedwith pipe-based cells

Pick the style the more appropriate

to your content

See WikiFormatting#Tables for details

on the pipe-based table syntax.

If one needs to add some

attributes to the table itself…

Left headerRight header

1.11.2

2.12.2

Note that by default tables are assigned the "wiki" CSS class, which gives a distinctive look to the header cells and a default border to the table and cells, as can be seen for the tables on this page. By removing this class (#!table class=""), one regains complete control on the table presentation. In particular, neither the table nor the rows nor the cells will have a border, so this is a more effective way to get such an effect rather than having to specify a style="border: no" parameter everywhere.

Wiki MarkupDisplay

{{{#!table class=""

|| 0|| 1|| 2||

|| 10|| 20|| 30||

|| 11|| 22|| 33||

||||||= numbers =||

}}}012

102030

112233

numbers

Other classes can be specified as alternatives (remember that you can define your own in site/style.css).

Wiki MarkupDisplay

{{{#!table class="listing"

|| 0|| 1|| 2||

|| 10|| 20|| 30||

|| 11|| 22|| 33||

||||||= numbers =||

}}}012

102030

112233

numbers

HTML comments

HTML comments are stripped from the output of the html processor. To add an HTML comment to a wiki page, use the htmlcomment processor, available since Trac 0.12:

Wiki Markup

{{{#!htmlcomment

This block is translated to an HTML comment.

It can contain and &entities; that will not be escaped in the output.

}}}

Display

The character sequence -- is not allowed in HTML comments, and will generate a rendering error.

More Information

​https://www.w3.org/ — World Wide Web Consortium

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值