用户工具

站点工具


wiki:syntax

WIKI语法手册

DokuWiki 支持一些简单的标记语言,它试图使数据文件尽可能地易读。 此页面包含您在编辑页面时可能使用的所有语法。只需按“编辑此页面”即可查看此页面的来源。 更简单的标记也可以通过quickbuttons轻松访问。

基本文本格式

DokuWiki 支持 粗体, 斜体, 下划线等宽 文本. 当然 混合体 你也可以使用.

DokuWiki 支持 **粗体**, //斜体//, __下划线__ 与 ''等宽'' 文本.
当然 **__//''混合体''//__** 你也可以使用.

您也可以使用 下标上标.

你也可以使用 <sub>下标</sub> 和 <sup>上标</sup>.

你也可以将某些东西标记为 已删除.

你也可以将某些东西标记为 <del>已删除</del>.

段落是从空行创建的。如果你想强制换行而不带段落,你可以使用两个反斜杠后跟一个空格或把两个反斜杠放在行尾。

这是一些带有换行符的文本
请注意, 两个反斜杠仅在行尾被识别
或紧随其后
一个空格 \\没有它就会发生这种没有换行的情况.

这是一些带有换行符的文本\\ 请注意,
两个反斜杠仅在行尾被识别\\
或紧随其后\\ 一个空格 \\没有它就会发生这种没有换行的情况.

链接

DokuWiki 支持多种创建链接的方式。

外部链接

外部链接会自动识别:http://www.google.com 或简写 www.google.com

您也可以设置链接文本: 此链接指向google.

像这样的电子邮件地址也可以识别: andi@splitbrain.org.

DokuWiki 支持多种创建链接的方式. 
外部链接会自动识别:http://www.google.com 或简写 www.google.com 
您也可以设置链接文本: [[http://www.google.com|此链接指向google]]. 
像这样的电子邮件地址也可以识别: <andi@splitbrain.org>.

内部链接

内部链接是使用方括号创建的。你可以只给出一个 页面名称 或使用其他的 链接文本

内部链接是使用方括号创建的。
你可以只给出一个 [[页面名称]] 或使用其他的 [[页面名称|链接文本]]。

Wiki 页面 名称会自动转换为小写,不允许使用特殊字符(比如中文)。

你可以通过冒号(:)来使用 命名空间

你可以通过冒号(:)来使用 [[some:命名空间]]。

查看更多关于 命名空间

通过井号(#)后添加锚点可实现链接至页面的 特定区域

链接至页面的 [[syntax#internal|特定区域]]。

注意:

  • 有效页面失效页面 的显示样式不同。
  • DokuWiki 并不自动使用 驼峰命名法,但在 配置文件 中 DokuWiki 会使用。提示:假如 DokuWiki 是一个有效的页面,它仍可被链接。
  • 请勿过度使用特定区域,因为当文档标题改变时它并不会同步改变。

内部维基

DokuWiki 支持 内部维基。内部维基可以快速地链接至 其他维基页面

DokuWiki 支持 [[doku>Interwiki|内部维基]]。内部维基可以快速地链接至 [[wp>Wiki|其他维基页面]]。

Windows Shares

DokuWiki 同样支持 Windows shares。此特性仅支持 同网络 下的用户使用。

DokuWiki 同样支持 [[\\server\share|Windows shares]]。

注意:

  • 为了安全,此功能默认只会在同网络下的 IE 浏览器中被启用。
  • 此文档 告诉你如何在火狐浏览器启用该功能。不幸的是 Javascript 仍会产生警告。在 conf/lang/en/lang.php 中追加以下代码可完美解决此问题(详见 此页):
    conf/lang/en/lang.php
    <?php
    /**
     * Customization of the english language file
     * Copy only the strings that needs to be modified
     */
    $lang['js']['nosmblinks'] = '';

图片链接

使用以下语法来引用图片:

[[http://php.net|{{wiki:dokuwiki-128.png}}]]

请注意:此语法是唯一可被链接名称接受的变种语法。

图片链接 的语法(包括调整图片大小、内外部图片、内部维基链接)已被 DokuWiki 完全支持。

脚注

使用双层括号来引用脚注 1)

使用双层括号来引用脚注 ((脚注))。

标题

DokuWiki 支持五种层级的标题。 倘若多于三个标题,DokuWiki 会自动生成一个表格,通过引用 ~~NOTOC~~ 来禁用此特性。

三级标题

四级标题

五级标题
==== 三级标题 ====
=== 四级标题 ===
== 五级标题 ==

使用大于 3 个的连续横杠(-)可产生一条分割线:


Media Files

通过花括号来引用 图片、视频和文件,并且可以重新定义它们的尺寸。 原始尺寸:

给定宽度:

给定宽度与高度 2)

外部图片:

原始尺寸:{{wiki:dokuwiki-128.png}}
给定宽度:{{wiki:dokuwiki-128.png?50}}
给定宽度与高度:{{wiki:dokuwiki-128.png?200x50}}
外部图片:{{https://secure.php.net/images/php.gif?200x50}}

在大括号内不同位置添加空格( )可改变图片的对齐方式:

{{ wiki:dokuwiki-128.png}}
{{wiki:dokuwiki-128.png }}
{{ wiki:dokuwiki-128.png }}

你还能给图片添加一个标题:

This is the caption

{{ wiki:dokuwiki-128.png |This is the caption}}

如果想通过图片来链接一个网页请看这里

支持的媒体

DokuWiki 可以直接引用以下类型的媒体:

图片 gif, jpg, png
视频 webm, ogv, mp4
音频 ogg, mp3, wav
Flash swf

倘若引用不被支持的类型,DokuWiki 会直接显示原始链接。

通过加入 ?linkonly 后缀会直接显示原始链接。

{{wiki:dokuwiki-128.png?linkonly}}

dokuwiki-128.png 是图片的原始链接。

运用多种备用格式

为了解决不同浏览器对同类文件不同格式的兼容性问题,你可以上传同一文件的不同格式。

例如你想引用这个视频:

{{video.mp4|A funny video}}

那么倘若你上传了 video.webm 以及 video.ogv,DokuWiki 会根据不同的浏览器来选择到底用哪个。

假如你上传了与视频同名的图片 video.jpg,DokuWiki 会在视频播放前显示它。

列表

Dokuwiki 支持有序列表与无序列表。 在文本前加入两个空格和一个 * 以创建无序列表,用 - 的话便是有序列表。

  • 这是一个列表
  • 这是第二个
    • 可以进行缩进操作
  • 另一个列表
  1. 有序的列表
  2. 另一个有序列表
    1. 另一个高端的缩进操作
  3. 是不是很方便?
  * 这是一个列表
  * 这是第二个
    * 可以进行缩进操作
  * 另一个列表

  - 有序的列表
  - 另一个有序列表
    - 另一个高端的缩进操作
  - 是不是很方便?

你可以看看这里来了解关于更多有关列表的内容。

文本转化

DokuWiki 可以转化一些特定的文本为别的一些内容。

一些文本会被转化成黄豆脸,一些文本会变成 HTML 中的特殊字符(可被用户自定义)。

Text to Image Conversions

一般来说,DokuWiki 会用表情来替换一些特定文本。用户可以扩展 DokuWiki 定义的黄豆脸以及其他的图片。例如:

  • 8-) 8-)
  • 8-O 8-O
  • :-( :-(
  • :-) :-)
  • =) =)
  • :-/ :-/
  • :-\ :-\
  • :-? :-?
  • :-D :-D
  • :-P :-P
  • :-O :-O
  • :-X :-X
  • :-| :-|
  • ;-) ;-)
  • ^_^ ^_^
  • m( m(
  • :?: :?:
  • :!: :!:
  • LOL LOL
  • FIXME FIXME
  • DELETEME DELETEME

特定文本转化为 HTML 字符

例如:

→ ← ↔ ⇒ ⇐ ⇔ » « – — 640×480 © ™ ® “他认为这是男人的世界……”

-> <- <-> => <= <=> >> << -- --- 640x480 (c) (tm) (r)
"他认为这是男人的世界……"

通过配置 pattern file 以实现替换更多的可识别字符。

然而有三个例外:乘号 (640×480), '单引号' and “双引号”. 通过配置 config option 来关闭这个奇怪的特性。

引用

通过以下语法来引用对话以及注释:

我认为我可以干

> 不,我们不能干

>> 好吧,我认为我们应该干

> 讲真?

>> 真!

>>> 那我们干吧

我认为我可以干

不,我们不能干
好吧,我认为我们应该干
讲真?
真!
那我们干吧

表格

DokuWiki 支持使用简单的语法来创建表格。

标题 1 标题 2 标题 3
Row 1 Col 1 Row 1 Col 2 Row 1 Col 3
Row 2 Col 1 some colspan (note the double pipe)
Row 3 Col 1 Row 3 Col 2 Row 3 Col 3

对于表格中的普通行,该行必须以“|”开头和结尾,对于标题,必须以“^”开头和结尾。

^ Heading 1      ^ Heading 2       ^ Heading 3          ^
| Row 1 Col 1    | Row 1 Col 2     | Row 1 Col 3        |
| Row 2 Col 1    | some colspan (note the double pipe) ||
| Row 3 Col 1    | Row 3 Col 2     | Row 3 Col 3        |

通过留白一单元以链接两个水平相邻的单元格(别忘了分隔符)。

DokuWiki 同样支持垂直的标题:

Heading 1 Heading 2
Heading 3 Row 1 Col 2 Row 1 Col 3
Heading 4 no colspan this time
Heading 5 Row 2 Col 2 Row 2 Col 3

同你所见,单元分隔符决定了该单元的格式:

|              ^ Heading 1            ^ Heading 2          ^
^ Heading 3    | Row 1 Col 2          | Row 1 Col 3        |
^ Heading 4    | no colspan this time |                    |
^ Heading 5    | Row 2 Col 2          | Row 2 Col 3        |

通过添加 ::: 连接垂直的单元格:

Heading 1 Heading 2 Heading 3
Row 1 Col 1 this cell spans vertically Row 1 Col 3
Row 2 Col 1 Row 2 Col 3
Row 3 Col 1 Row 2 Col 3

除了行合并语法之外,这些单元格不应包含任何其他内容

^ Heading 1      ^ Heading 2                  ^ Heading 3          ^
| Row 1 Col 1    | this cell spans vertically | Row 1 Col 3        |
| Row 2 Col 1    | :::                        | Row 2 Col 3        |
| Row 3 Col 1    | :::                        | Row 2 Col 3        |

你可以对表格的内容进行对齐操作。例如:

Table with alignment
right center left
left right center
xxxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxx

看看源码长的样子:

^           Table with alignment           ^^^
|         right|    center    |left          |
|left          |         right|    center    |
| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx |

注意:垂直对齐并不支持。

保留原格式

如果您需要显示与键入的文本完全相同的文本(不带任何格式), 请使用<nowiki> 标记或更简单的双百分号%%将该区域括起来.

这是一些包含如下地址的文本: http://www.splitbrain.org 和 **formatting**, 但没有对其进行任何操作。 对于带有笑脸的也是如此//__this__ text// with a smiley ;-).

<nowiki>
This is some text which contains addresses like this: http://www.splitbrain.org and **formatting**, but nothing is done with it.
</nowiki>
The same is true for %%//__this__ text// with a smiley ;-)%%.

代码块

您可以通过将代码块缩进至少两个空格(如前面的示例中使用的那样)或使用标签<code><file>将代码块包含到文档中.

This is text is indented by two spaces.
This is preformatted code all spaces are preserved: like              <-this
This is pretty much the same, but you could use it to show that you quoted a file.

看看代码长的样子:

  This is text is indented by two spaces.
<code>
This is preformatted code all spaces are preserved: like              <-this
</code>
<file>
This is pretty much the same, but you could use it to show that you quoted a file.
</file>

语法高亮

DokuWiki 使用 GeSHi 来高亮代码。在 <code java><file java> 标签中启用该功能。

/**
 * The HelloWorldApp class implements an application that
 * simply displays "Hello World!" to the standard output.
 */
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); //Display the string.
    }
}

以下的标识符会被识别为高亮: 4cs 6502acme 6502kickass 6502tasm 68000devpac abap actionscript3 actionscript ada aimms algol68 apache applescript apt_sources arm asm asp asymptote autoconf autohotkey autoit avisynth awk bascomavr bash basic4gl batch bf biblatex bibtex blitzbasic bnf boo caddcl cadlisp ceylon cfd cfm chaiscript chapel cil c_loadrunner clojure c_mac cmake cobol coffeescript c cpp cpp-qt cpp-winapi csharp css cuesheet c_winapi dart dcl dcpu16 dcsDelphi diff div dos dot d ecmascript Eiffel email EPC e erlang Euphoria ezt F1 Falcon fo Fortran FreeBasic FreeSwitch Fsharp Gambas GDB Genero Genie Genie GetText GLSL GML gnuplot Go groovy GWbasic Haskell Haxe Hicest hq9plus HTML HTML4strict HTML5 icon idl ini inno intercal io ispfpanel Java5 Java JavaScript JCL j jquery julia kixtart klonec klonecpp kotlin latex lb ldif lisp llvm locobasic logtalk lolcode lotusformulas lotusscript lscript lsl2 lua m68k magiksf make mapbasic mathematicaMatLab Mercury Metapost Mirc MK-61 mmix modula2 modula3 mpasm mxml mysql nagios netrexx newlisp nginx nimrod nsis oberon2 objc objeck ocaml-brief ocaml octave oobas oorexx oracle11 oracle8 oxygene oz parasail parigp pascal pcre perl6 perl per pf phix php-brief php pic16 pike pixelbender pli plsql postgresql postscript povray Powerbuilder PowerShell proftPD Progress Prolog Properties ProvideX pureBasic Pycon PyS60 Python Qbasic QML Q Racket Rails RBS Rebol Reg Rexx Robots Roff rpmspec RSPLUS RubyRust sas sass scala scheme scilab scl sdlbasic smalltalk smarty spark sparql SQL sshconfig standardml stonescript swift systemverilog tclegg tcl teraterm texgraph text thinbasic tsql twig typoscript unicon upc urbi uscript vala vbnet vb vbscript vedit verilog vhdl vim visualfoxpro visualprolog whitespace whois winbatch wolfram xbasic xml xojo xorg_conf XPP YAML Z80 ZXBASIC

点击这里了解更多高级的内容。

可下载的代码块

倘若你使用上述的 <code> 以及 <file> 语法,你可能想用户该如何下载引用的代码,很简单:

<file php myexample.php>
<?php echo "hello world!"; ?>
</file>
myexample.php
<?php echo "hello world!"; ?>

使用横杠(-)来禁用语法高亮:<code - myfile.foo>

嵌入 HTML和PHP

通过使用 <html> or <php> 标签来嵌入原始 HTML 和 PHP 代码。(如果想要包含块级元素,请使用大写的标签)

HTML 的例子:

<html>
This is some <span style="color:red;font-size:150%;">inline HTML</span>
</html>
<HTML>
<p style="border:2px dashed red;">And this is some block HTML</p>
</HTML>

<html> This is some inline HTML </html> <HTML> <p style=“border:2px dashed red;”>And this is some block HTML</p> </HTML>

PHP 的例子:

<php>
echo 'The PHP version: ';
echo phpversion();
echo ' (generated inline HTML)';
</php>
<PHP>
echo '<table class="inline"><tr><td>The same, but inside a block level element:</td>';
echo '<td>'.phpversion().'</td>';
echo '</tr></table>';
</PHP>

<php> echo 'The PHP version: '; echo phpversion(); echo ' (inline HTML)'; </php> <PHP> echo '

<tr><td>The same, but inside a block level element:</td>'; echo '<td>'.phpversion().'</td>'; echo '</tr>

'; </PHP>

请注意:嵌入的 HTML 与 PHP 默认只被显示源代码,并不被执行。

RSS/ATOM源聚合

DokuWiki 以集成来自外部XML源的数据。为了解析XML源,使用了SimplePie . SimplePie理解的所有格式也可以在DokuWiki中使用。您可以通过多个额外的空格分隔参数来影响渲染:

参数 描述
any number 将用作要显示的最大项目数,默认为 8
reverse 首先显示feed中的最后一项
author 显示项目作者姓名
date 显示项目日期
description 显示项目描述。如果HTML不可用,那么所有HTML标签都将被去除
nosort 不 Feed 中的项目进行排序
n[dhm] 刷新周期,其中 d=天,h=小时,m=分钟。(例如 12 小时 = 12 小时).

刷新周期默认为 4 小时,任何低于 10 分钟的值都将被视为 10 分钟。 DokuWiki 常会尝试提供页面的缓存版本,显然当页面包含动态外部内容时,这是不合适的。该参数告诉 DokuWiki 如果渲染页面的时间超过了刷新周期,则会重新渲染页面。 默认情况下,Feed 将按日期排序,最新项目排在最前面。 你可以使用reverse参数按照最旧排序或者使用nosort按原样显示。

例子:

{{rss>http://slashdot.org/index.rss 5 author date 1h }}

控制宏

部分宏可以影响 DokuWiki 在页面中的渲染。例如:

描述
~~NOTOC~~ 禁用表格
~~NOCACHE~~ 默认 DokuWiki 会缓存所有的页面输出。但有时候你可能并不想要这个特性(例如使用了<php>语法),引用此宏可以强制让 DokuWiki 在每次被调用时重新渲染页面

语法插件

可以通过插件来扩展 DokuWiki 的语法。你可以通过以下的链接来了解对应插件的用法:

1)
脚注
2)
当给定的长宽比与原始的不匹配时,DokuWiki 会先裁剪图片,再调整图片大小
wiki/syntax.txt · 最后更改: 2023/08/04 14:46 由 弘毅