Wiki格式
Wiki标记是Trac的核心功能,它将Trac的所有其他部分紧密集成到一个灵活统一的整体中。
Trac拥有强大的Wiki渲染引擎,它实现了其他流行Wiki(如MoinMoin和WikiCreole)的部分命令。
以下章节概述了最常用语法,类别列中的每个链接将引导您查看本页后面更详细的解释。
以下Wiki页面更深入地介绍了Trac Wiki标记的高级功能
- TracLinks涵盖了引用任何Trac资源或其部分的所有可能方式。
- WikiPageNames涵盖了Wiki页面可以采用的各种名称,无论是否使用CamelCase。
- WikiMacros列出了可用于生成动态内容的宏。
- WikiProcessors和WikiHtml详细介绍了Wiki文本的某些部分如何以特殊方式进行处理。
- AdvancedWikiOperations在不常见或管理场景中提供了一些操作。
常用Wiki标记
| 类别 | 维基标记 | 显示 | ||||
|---|---|---|---|---|---|---|
'''bold''', ''italic'', '''''Wikipedia style''''' | 粗体, 斜体, 维基百科样式 | |||||
**bold**, //italic//, **//!WikiCreole style//** | 粗体, 斜体, WikiCreole样式 | |||||
`等宽字体 (''其他标记被忽略'')`
| 等宽字体 (''其他标记被忽略'')
| |||||
| 标题 | == Level 2 === Level 3 ^([#hn note])^ | 二级三级 (注意) | ||||
| 段落 | First paragraph on multiple lines. Second paragraph. | 多行的第一段。 第二段。 | ||||
| 列表 | * bullet list
on multiple lines
1. nested list
a. different numbering
styles
|
| ||||
term:: definition on
multiple lines
|
| |||||
| 预格式文本 | {{{
multiple lines, ''no wiki'',
white space respected
}}}
| multiple lines, ''no wiki'',
white space respected
| ||||
| 块引用 | if there's some leading space the text is quoted |
| ||||
| 讨论引用 | >> ... (I said) > (he replied) |
| ||||
| 表格 | ||= Table Header =|| Cell || |||| (details below) || |
| ||||
https://trac.edgewall.org
| https://trac.edgewall.org | |||||
WikiFormatting (CamelCase)
| WikiFormatting (CamelCase) | |||||
wiki:WikiFormatting, wiki:"WikiFormatting" | wiki:WikiFormatting, wiki:"WikiFormatting" | |||||
#1 (工单), [1] (变更集), {1} (报告) | #1 (工单), [1] (变更集), {1} (报告) | |||||
ticket:1, ticket:1#comment:1, comment:1:ticket:1
| ticket:1, ticket:1#comment:1, comment:1:ticket:1 | |||||
工单 [ticket:1], [ticket:1 工单 一] | 工单 1, 工单 一 | |||||
工单 [[ticket:1]], [[ticket:1|工单 一]] | 工单 1, 工单 一 | |||||
[=#point1 (1)] 首先...
| (1) 首先... | |||||
参见 [#point1 (1)]
| 参见 (1) | |||||
!'' 双引号
| '' 双引号 | |||||
!wiki:WikiFormatting, !WikiFormatting | wiki:WikiFormatting, WikiFormatting | |||||
`{{{-}}} 三重花括号`
| {{{-}}} 三重花括号 | |||||
| 图片 | [[Image(链接)]] |
| ||||
[[MacroList(*)]] | (所有可用宏的简短列表) | |||||
[[Image?]] | (Image宏的帮助) | |||||
| 处理器 | {{{#!div style="font-size: 80%"
Code highlighting:
{{{#!python
hello = lambda: "world"
}}}
}}}
| 代码高亮 hello = lambda: "world" | ||||
| 注释 | {{{#!comment
Note to Editors: ...
}}}
| (注释仅在编辑模式下显示) | ||||
| 其他 | Line [[br]] break Line \\ break ---- | 行 | ||||
字体样式
Trac Wiki支持以下字体样式
| 维基标记 | 显示 |
|---|---|
* '''bold''',
''' triple quotes !'''
can be bold too if prefixed by ! ''',
* ''italic''
* '''''bold italic''''' or ''italic and
''' italic bold ''' ''
* __underline__
* {{{monospace}}} or `monospace`
(hence `{{{` or {{{`}}} quoting)
* ~~strike-through~~
* ^superscript^
* ,,subscript,,
* **also bold**, //italic as well//,
and **'' bold italic **'' //(since 0.12)//
* [[span(style=color: #FF0000, a red text )]]
|
|
备注
{{{...}}}和`...`命令不仅选择等宽字体,还将它们的内容视为原样文本,这意味着此文本不会进行进一步的Wiki处理。!告诉Wiki解析器不要将后续字符视为Wiki格式,因此请注意在!后面加上一个空格,例如在粗体结束时。- 所有字体样式标记都必须成对使用(开头/结尾),并且必须正确嵌套;特别是,
''斜体不能与//配对,而'''不能与**配对。
标题
您可以通过以一个到六个等号字符(=)开头,后跟一个空格和标题文本来创建标题。
标题文本可以后跟相同数量的=字符,但这并非强制要求。也就是说,=== Section3 === 与 === Section3 相同。
最后,标题可以选择后跟一个显式ID。如果没有,将生成一个隐式但可读的ID。
| 维基标记 | 显示 |
|---|---|
= Heading = == Subheading === About ''this'' === === Explicit id === #using-explicit-id-in-heading == Subheading #sub2 | 标题副标题关于这显式ID副标题 |
段落
当两个文本块由一个或多个空行分隔时,会创建一个新的文本段落。
也可以插入强制换行符,使用
| 维基标记 | 显示 |
|---|---|
Line 1[[BR]]Line 2 Paragraph one Paragraph two |
|
列表
Wiki支持有序/编号列表和无序列表。
| 维基标记 | 显示 |
|---|---|
* Item 1
* Item 1.1
* Item 1.1.1
* Item 1.1.2
* Item 1.1.3
* Item 1.2
* Item 2
- items can start at the beginning of a line
and they can span multiple lines
- be careful though to continue the line
with the appropriate indentation, otherwise
that will start a new paragraph...
1. Item 1
a. Item 1.a
a. Item 1.b
i. Item 1.b.i
i. Item 1.b.ii
1. Item 2
And numbered lists can also be restarted
with an explicit number:
3. Item 3
|
那将开始一个新的段落...
编号列表也可以用显式数字重新开始
|
定义列表
Wiki也支持定义列表。
| 维基标记 | 显示 |
|---|---|
llama:: some kind of mammal, with hair ppython:: some kind of reptile, without hair (can you spot the typo?) |
|
请注意,您需要在定义术语前留一个空格。
预格式文本
包含预格式化文本的块适用于源代码片段、注释和示例。使用三个花括号将文本包围起来以定义一个块引用。花括号需要单独占一行。
| 维基标记 | 显示 |
|---|---|
{{{
def HelloWorld():
print '''Hello World'''
}}}
| def HelloWorld():
print '''Hello World'''
|
请注意,这种块也用于选择应通过WikiProcessors处理的行。
块引用
为了将段落标记为块引用,请将该段落缩进两个空格。
| 维基标记 | 显示 |
|---|---|
Paragraph This text is a quote from someone else. | 段落
|
讨论引用
为了在正在进行的讨论线程(例如工单评论区)中划分引用,可以使用类似电子邮件的引用标记(>, >>等)。
| 维基标记 | 显示 |
|---|---|
>> Someone's original text > Someone else's reply text > - which can be any kind of Wiki markup My reply text |
我的回复文本 |
表格
简单表格
可以创建简单表格
| 维基标记 | 显示 | ||||||
|---|---|---|---|---|---|---|---|
||Cell 1||Cell 2||Cell 3|| ||Cell 4||Cell 5||Cell 6|| |
|
单元格标题可以通过将内容用一对=字符包裹来指定。请注意,=字符必须紧贴单元格分隔符
| 维基标记 | 显示 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|| ||= stable =||= latest =|| ||= 0.10 =|| 0.10.5 || 0.10.6dev|| ||= 0.11 =|| 0.11.6 || 0.11.7dev|| |
|
最后,指定一个空单元格意味着下一个非空单元格将跨越这些空单元格
| 维基标记 | 显示 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|| 1 || 2 || 3 || |||| 1-2 || 3 || || 1 |||| 2-3 || |||||| 1-2-3 || |
| ||||||||||||
请注意,如果单元格内容仅贴靠单元格一侧,则文本将对齐到该侧
| 维基标记 | 显示 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
||=Text =||= Numbers =|| ||left align || 1.0|| || center || 4.5|| || right align|| 4.5|| || default alignment || 2.5|| ||default|| 2.5|| || default || 2.5|| || default || 2.5|| |
|
如果与上述示例相反,表格中的单元格包含更多文本,将表格行分散到多行标记上可能会很方便。在单元格分隔符后、行尾放置的\字符会告诉Trac不对下一行的单元格开始新行
| 维基标记 | |||
|---|---|---|---|
|| this is column 1 [https://trac.edgewall.org/newticket new ticket] || \ || this is column 2 [https://trac.edgewall.org/roadmap the road ahead] || \ || that's column 3 and last one || | |||
| 显示 | |||
|
复杂表格
如果上述简单管道式标记(||)提供的表格功能无法满足您的需求,您可以使用基于WikiProcessor的表格来创建更复杂的表格。
链接
超链接会自动为WikiPageNames和URL创建。WikiPage链接可以通过在其前面加上感叹号(!)来禁用,例如!WikiPageLink。
| 维基标记 | 显示 |
|---|---|
TitleIndex, https://www.edgewall.com/, !NotAlink | TitleIndex, https://www.edgewall.com/, NotAlink |
可以通过在链接后加上一个空格和标题,并将所有内容放在方括号内来为链接提供更具描述性的标题。如果省略描述性标题,则会丢弃显式前缀,除非该链接是外部链接。这对于不遵循WikiPageNames约定的Wiki页面很有用。
| 维基标记 | 显示 |
|---|---|
* [https://www.edgewall.com Edgewall Software] * [wiki:TitleIndex Title Index] * [wiki:TitleIndex] * [wiki:ISO9000] |
遵循WikiCreole趋势,描述性标题也可以通过在链接后加上管道符(|)和标题,并将所有内容放在双方括号内来指定。
* [[https://www.edgewall.com|Edgewall Software]] * [[wiki:TitleIndex|Title Index]] or even [[TitleIndex|Title Index]] * [[wiki:TitleIndex]] ''' but not ![[TitleIndex]]! ''' * [[ISO9000]] |
|
注意:WikiCreole样式的链接输入快速,并且看起来很熟悉,因为它在维基百科和许多其他Wiki中使用。不幸的是,它与宏的语法冲突。因此,在极少数情况下,当您需要引用一个以宏命名的页面(典型示例有TitleIndex、InterTrac和InterWiki)时,编写[[TitleIndex]]实际上会调用宏而不是链接到页面。
Trac链接
Wiki页面可以直接链接到Trac系统的其他部分。页面可以使用以下标记引用工单、报告、变更集、里程碑、源文件以及其他Wiki页面
| 维基标记 | 显示 |
|---|---|
* Tickets: #1 or ticket:1
* Reports: {1} or report:1
* Changesets: r1, [1] or changeset:1
* ...
* targeting other Trac instances,
so called InterTrac links:
- Tickets: #Trac1 or Trac:ticket:1
- Changesets: [Trac1] or Trac:changeset:1
|
|
Trac链接有更多类型,请参阅TracLinks以获取更深入的信息和所有默认链接解析器的参考。
设置锚点
锚点,或者更准确地说,是锚点名称,可以显式地添加到Wiki页面的任何位置,以唯一标识文档中的位置
[=#point1]
选择此语法是为了与上方文档中显式命名标题ID的格式匹配
== Long title == #title
它也非常接近指向该锚点的相应链接的语法
[#point1]
锚点可以选择给定一个标签
[=#point1 '''Point 1''']
| 维基标记 | 显示 |
|---|---|
[#point2 jump to the second point] ... Point2: [=#point2] Jump here |
|
对于更复杂的锚点(例如需要自定义标题时),您可以使用Span宏:[[span(id=point2, class=wikianchor, title=点2, ^(2)^)]]。
转义链接、WikiPageNames及其他标记
您可以通过在表达式前加上一个感叹号(!)来避免将TracLinks转换为超链接。
| 维基标记 | 显示 |
|---|---|
!NoHyperLink !#42 is not a link Various forms of escaping for list markup: ^^- escaped minus sign \\ ^^1. escaped number \\ ^^* escaped asterisk sign |
列表标记的各种转义形式
|
图片
以.png、.gif或.jpg结尾的URL不再自动解释为图片链接,并转换为<img>标签。
您现在必须使用[[Image]]宏。包含图片最简单的方法是将其作为附件上传到当前页面,并将文件名放在宏调用中,例如[[Image(picture.gif)]]。
除了当前页面,还可以引用其他资源
[[Image(wiki:WikiFormatting:picture.gif)]](引用另一页上的附件)[[Image(ticket:1:picture.gif)]](附加到工单的文件)[[Image(htdocs:picture.gif)]](引用环境htdocs目录中的文件)[[Image(source:/trunk/trac/htdocs/trac_logo_mini.png)]](仓库中的文件)
| 维基标记 | 显示 |
|---|---|
[[Image(htdocs:../common/trac_logo_mini.png)]] |
请参阅WikiMacros以获取更多关于[[Image()]]宏的文档,它有几个有用的选项(title=, link=, 等)。
宏
宏是自定义函数,用于在页面中插入动态内容。
| 维基标记 | 显示 |
|---|---|
[[RecentChanges(Trac,3)]] |
06/02/2023
|
请参阅WikiMacros以获取更多信息,以及已安装宏的列表。
特定宏的详细帮助也可以通过在宏名称后附加一个?来更直接地获取。
| 维基标记 | 显示 |
|---|---|
[[MacroList?]] |
|
处理器
Trac支持使用WikiProcessors的替代标记格式。例如,处理器用于以reStructuredText或HTML编写页面。
| 维基标记 | 显示 | |||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
{{{#!html
<h1 style="text-align: right; color: blue">
HTML Test
</h1>
}}}
| HTML测试 | |||||||
| ||||||||
{{{#!python
class Test:
def __init__(self):
print "Hello World"
if __name__ == '__main__':
Test()
}}}
| class Test: def __init__(self): print "Hello World" if __name__ == '__main__': Test() | |||||||
| ||||||||
{{{#!th rowspan=4 align=justify
With the `#td` and `#th` processors,
table cells can contain any content:
}}}
|----------------
{{{#!td
- lists
- embedded tables
- simple multiline content
}}}
|----------------
{{{#!td
As processors can be easily nested,
so can be tables:
{{{#!th
Example:
}}}
{{{#!td style="background: #eef"
|| must be at the third level now... ||
}}}
}}}
|----------------
{{{#!td
Even when you don't have complex markup,
this form of table cells can be convenient
to write content on multiple lines.
}}}
|
| |||||||
请参阅WikiProcessors以获取更多信息。
注释
注释可以添加到纯文本中。它们不会被渲染,也不会以纯文本以外的任何其他格式显示。
| 维基标记 | 显示 |
|---|---|
Nothing to
{{{#!comment
Your comment for editors here
}}}
see.
|
|
其他
| 维基标记 | 显示 |
|---|---|
| 四个或更多破折号将被水平线(<HR>)替换 看到了吗? |
| “宏”样式 WikiCreole样式 |


