Wiki Styles China
authors (basic)
Wikistyle basics
WikiStyles允许作者修改页面内容(如文字)的颜色或其它属性.Wikistyle使用百分比符号所写成,例如%red%
或者是%bgcolor=blue%
.
最基本的wikistyles是改变文字属性,例如文字颜色、背景颜色以及字型。PmWiki 定义了数种改变文字颜色的方法%black%, %white%, %red%, %yellow%, %blue%, %gray%, %silver%, %maroon%, %green%, %navy%, and %purple%。
篮子里有%red%苹果,%blue%蓝苺,%purple%茄子,%green%来姆果 ,%%以及其它水果. |
篮子里有苹果,蓝苺,茄子,来姆果 ,以及其它水果. |
对於未定义名称的颜色,必须使用%color=...%
这样的格式。(注:为避免与WikiWord?混淆,RGB颜色(#rrggbb)定义务必使用小写字母.)
我也想来点%color=#ff7f00%桔子%%! |
我也想来点桔子! |
使用%bgcolor=...%
来设定背景颜色:
这个句子有%bgcolor=green yellow%绿底黄字的设定. |
这个句子有绿底黄字的设定. |
See PmWiki:WikiStyleColors for more color help.
Scopes
Wikistyles可以设定套用的scope;倘若不设定scope,则样式会一直生效,直到下一个样式定义,或者到达段落结尾。使用时在样式定义前加上范围修饰字即可.例如套用到整个段落(%p ...%
),整份清单(%list ...%
),清单项目(%item ...%
)以及任何的区块(%block ...%
).scope用"apply="来预定义, 具体见below.
%p bgcolor=#ffeeee%段落最前面的样式定义会套用在整个段落内容上,即使里头又定义了%blue%其它的样式%%. |
段落最前面的样式定义会套用在整个段落内容上,即使里头又定义了其它的样式. |
>>style<<
区块能将样式套用到自定范围的页面内容中。样式区块会一直作用直到下一个>><<
.
>>blue font-style=italic bgcolor=#ffffcc<< 上一行後所有内容的样式皆为蓝色斜体字, 包括了 预先格式化文字 * 清单 -> 缩进项目 >><< |
上一行後所有内容的样式皆为蓝色斜体字, 包括了 预先格式化文字
缩进项目
|
Wikistyle attributes
The style attributes recognized within a wikistyle specification are:
------------ CSS ------------- --HTML-- color bgcolor class background-color margin id text-align padding hspace text-decoration border vspace font-size float target font-family list-style rel font-weight width* accesskey font-style height* value display Special: define, apply
The attributes in the first two columns correspond to the cascading style sheet (CSS) properties of the same name. The attributes in the last column apply only to specific items:
class=
andid=
assign a CSS class or identifier to an HTML elementtarget=name
opens links that follow in a browser window called "name"rel=name
in a link identifies the relationship of a target pageaccesskey=x
uses 'x' as a shortcut key for the link that followsvalue=9
sets the number of the current ordered list item
* The width and height attributes have asterisks because they are handled specially for <img .../> tags. If used by themselves (i.e., without anything providing an "apply=" parameter to the wikistyle), then they set the 'width=' and 'height=' attributes of any <img ... /> tags that follow. Otherwise, they set the 'width:' and 'height:' properties of the element being styled.
Applying wikistyles to blocks
Normally a wikistyle applies to a span of (inline) text, but the apply= attribute allows a style to be applied to something else. The predefined apply= values are:
apply=img | apply the style to any image that follows | |
apply=p | apply the style to the current paragraph | * |
apply=pre | apply the style to the current preformatted text | |
apply=list | apply the style to the current list | * |
apply=item | apply the style to the current list item | * |
apply=div | apply the style to the current div | |
apply=block | apply the style to the current block, whether it's a paragraph, list, list item, heading, or division. | * |
The starred items also have wikistyle shortcuts already defined,
thus %p color=blue%
is the same as %apply=p color=blue%
, and
%list ROMAN%
is the same as %apply=list list-style=upper-roman%
.
Some wikistyle shortcuts also make use of apply, thus %right%
is a shortcut for %text-align=right apply=block%
.
An applied wikistyle will only take effect if it's on the line that starts the thing it's supposed to modify. In other words, a wikistyle in the third markup line of a paragraph can't change the attributes of the paragraph:
here is some text in a paragraph and if we try to %apply=p color=blue% change the color of the paragraph in the middle it won't work because the style comes after the paragraph has already been started. |
here is some text in a paragraph and if we try to change the color of the paragraph in the middle it won't work because the style comes after the paragraph has already been started. |
However, this %p color=red% paragraph ''will'' be in red because its block style does occur in the first line of its text. |
However, this paragraph will be in red because its block style does occur in the first line of its text. |
* Here's a list item * %list red% Oops, too late to affect the list! |
|
Enabling Styles
Styles not listed above can be enabled by a PMWiki Adminstrator by modifying the local/config.php file. For instance to enable the "line-height" style attribute add the line
$WikiStyleCSS[] = 'line-height';
to the local/config.php file.
Custom style shortcuts
define=
属性可用来为任何wiki样式定义命一个缩写。之后的文章使用这个缩写,即可重覆利用这个样式定义。
%define=box block bgcolor=#ddddff border="2px dotted blue"% %box% [@ $ echo "Hello world" Hello World $ exit @] %box font-weight=bold color=green% [@ $ echo "I said, HELLO" @] |
$ echo "Hello world" Hello World $ exit $ echo "I said, HELLO" |
Tip: 将常用的样式缩写集中放在Group Header?页面中,以便群组里头所有的页面都能利用这些缩写。wiki administrator?可以在local customization?先定义一些套用于整个系统的样式缩写(详见CustomWikiStyles?)
Tip: 样式缩写应命名成有意义的字词,而不是直接用颜色名字。比如说如果警告讯息要用绿色字,则设定缩写为%define=warn green%
,并使用%warn%
来套用警告样式,而非使用%green%
。之後若决定变换警告样式,则只要修改%define=warn green%
,所有%warn%
就会跟着变换。这样比起一个一个换掉%green%
来得容易多了
Tip: Any undefined WikiStyle is automatically treated as a request for a class, thus %pre%
is the same as saying %class=pre%
.
Predefined style shortcuts
PmWiki预先设定了一些样式缩写
- 文字颜色: black, white, red, yellow, blue, gray, silver, maroon, green, navy, purple (用
%color=...%
) - 对齐方式:
%center%
和%right%
- 图片与格子
- 向右浮动、向左浮动:
%rfloat%
和%lfloat%
- 框架项目:
%frame%
,%rframe%
, 和%lframe%
- 缩略图:
%thumb%
- 向右浮动、向左浮动:
- 在新窗口中打开:
%newwin%
(使用%target=_blank%
) - 注释:
%comment%
(使用%display=none%
) - 有序列表:
%decimal%
,%roman%
,%ROMAN%
,%alpha%
,%ALPHA%
(参照 Cookbook:OutlineLists)
Examples
WikiStyleExamples页面有许多wiki样式的使用范例.
Known Issues
- 在样式定义中,百分比符号(%)无法正确作用(例如:
%block width=50% %
需要使用 "pct" 来代替 "%".
See Also
<< | Documentation Index? | >>