文档编辑方式说明

新的网站已经建成,Drupan平台无论从灵活性、易用性与稳定性来讲都是出类拨粹的。

输入方式最终决定使用BBcode + Markdown,本手册的目的在于为使用它们提供帮助。

BBcode Help

This document uses (almost) all BBCode tags supported by Drupal's BBCode module. You can cut and paste this document into a node to test Drupal's BBCode implementation or to perform some benchmarks.

  1. Normal text formatting
  2. Font colors
  3. Font sizes
  4. Font faces
  5. Text alignment
  6. Images
  7. URL's
  8. E-mail addresses
  9. Headings
  10. Level 1 Heading
    1. Level 2 Heading
      1. Level 3 Heading
        1. Level 4 Heading
  11. Acronyms and abbreviations
  12. Code blocks
  13. Quoting
  14. Lists
  15. Table tags
  16. Other tags
  17. Tag nesting
  18. Test multi-line tags:
  19. Cross site scripting (XSS) vulnerabilities
  20. Broken tags


Normal text formatting


Test bold / strong text
Test italic / emphasised text
Test underlined text
Test strikeout text
Test subscript text - H2O
Test superscript text - X3

Font colors


Test blue text
Test red text
Test green text
Test #eeff00 text

Font sizes


Test 1px - too small, normalized to 6px
Test 12px text
Test 24px text
Test 100px - too big, normalized to 48px

Font faces


Test Arial typeface text
Test Arial typeface text
Test Courier typeface text
Test Courier New typeface text
Test Impact typeface text
Test Helvetica typeface text
Test Times New Roman typeface text
Test Verdana typeface text

Text alignment


Left hand side of the screen

Right hand side of the screen

Centered

This paragraph is justified on both sided on the page. By default most browsers render text with a jagged right edge. If you want all text rendered like in a book with an even right edge - use the justify tag.

Images

Normal image:

Align image right:

Image with ALT description:
The Dripal Logo

Re-sized image:

URL's


www.test-url.com
ftp.test-url.com
http://test-url.com/~user/,part,of,url
ftp://test-url.com:8080/
http://test-url.com/
Test URL

Anchor (bookmark you can link to):
URL Anchor

Some URL's within a sentence: http://url1.com; www.url2.com, (www.url3.com) and www.url4.com. And some more: ftp://url5.com/, (ftp.url6.com/) and ftp.url7.com.

Google link: BBCode
Wikipedia link: BBCode

E-mail addresses





Headings


Level 1 Heading


Level 2 Heading


Level 3 Heading


Level 4 Heading

Acronyms and abbreviations


Abbreviations:
API
CMS
WWW
1 inch

Acronyms:
SQL
GIF
radar

Code blocks

Normal code block:

x := y + z;
y := a - b;

An

inline code
block

Color highlighted PHP code block:



<?php
  echo "Sample PHP code";
?>

Test notag:
These BBCode tags are [b]not[/b] converted to HTML!
[size=20]I'm happy[/size]

Quoting

A simple quote:

This is a quoted message

Quote with source:

Frank wrote:

This is a quoted message

Nested quotes:

Gabor wrote:

This is a quoted message

Alastair wrote:

This is a nested quote


Lists

A normal list (circular bullets, same as list=c):

  1. x
  2. y
  3. z

List with discs (list=d):

  1. x
  2. y
  3. z

List with squares (list=s):

  1. x
  2. y
  3. z

Numeric list (list=1):

  1. x
  2. y
  3. z

Roman lowercase list (list=i):

  1. x
  2. y
  3. z

Roman uppercase list (list=I):

  1. x
  2. y
  3. z

Alfa lowercase list (list=a):

  1. x
  2. y
  3. z

Alfa uppercase list (list=A):

  1. x
  2. y
  3. z

A nested list:

  1. x
    1. x.1
    2. x.2
  2. y
  3. z

Table tags

row1col1 row1col2
row2col1 row2col2





Header1 Header2
row1col1 row1col2
row2col1 row2col2

Other tags

Test marquee:
Move tag - creates a scrolling display

Horizontal delimiter:


Force line break:
-->
<--

Force space:
--> <--

Tag nesting


large red text
again - large red test with different tag order

Test multi-line tags:




test

Cross site scripting (XSS) vulnerabilities


User-entered text with embedded script tags alert(document.cookie); will be encoded.

Some other exploits:
[size=expression(alert(document.cookie));]Size tag[/size]
[font=expression(alert(document.cookie));]Font tag[/font]
[float=expression(alert(document.cookie));]Float tag[/float]
[url=javascript:alert(document.cookie)]Click here to see cookie[/url]
[anchor=javascript:alert(document.cookie)]Anchor[/anchor]
[img]javascript:document.location='http://www.albinoblacksheep.com/flash/you.html'[/img]
[img]javascript:al&#x65rt('XSS')[/img]
http://host.com/?act=SR&f='>alert(document.cookie)

Broken tags


We need to ensure that bad formating will not disrupt your site's HTML.

Broken [b]bold text...

  1. A broken list...

    A broken quote...

Markdown: 基础

Markdown 格式化语法之要旨

Markdown 使用起来是什么样子?这个页面提供了一点概观性的介绍。而更完整详尽的文档在语法页面中,那儿包括了所有特性的说明——其实在看过几个 Markdown 的例子后你就足以了解大要了。所以,下面的例子就用处理前后结果的对比来展示 Markdown 的用法。

在阅读的同时试一试也是很有必要的,Dingus 这个程序可以让你在线输入用 Markdown 标记的文本,并将它转换成 XHTML。

注意:这份文档本身也是用 Markdown 写就的。你可以通过这个链接找到它的源代码。
段落,标题,Blockquotes

所谓段落不过是一行或者数行连续的文本,段落之间通过一个或者数个空行分隔 (而只要看起来像一行空白的就算是“空行”了,比如说只包含空格和 Tab 的一行,也算作空行。),这里的段落在开头不需要——也不应当——用空格或者 Tab 来缩进。

Markdown 提供了两种风格的标题:Setext 和 atx。Setext 风格的 <‘h1’> 和 <‘h2’> 是分别通过在标题的文本下边一行加上等号 (=) 或者连字符 (-) 组成的。若要创建 atx 风格的标题,你可以在把 1-6 个井号 (#) 放在标题那一行的前头——井号的数量就对应着结果中 HTML 标题的级别。

Blockquotes (引用区块) 则是通过 email 风格的 '>' 尖括号表示的。

Markdown:

一级标题
========
二级标题
--------
有一座小山旁边,住着一匹老马和一匹小马。
小马整天跟着妈妈,从来不肯离开一步。这只
不过是一段常见的文本。
小马停住脚抬头一看,原来是一只小松鼠。
### 三级标题
> 这是一个 blockquote。
>
> 这是引用区块的第二段。
>
> ## 这是一个 blockquote 中的 H2

输出:

一级标题

二级标题

有一座小山旁边,住着一匹老马和一匹小马。
小马整天跟着妈妈,从来不肯离开一步。这只
不过是一段常见的文本。

小马停住脚抬头一看,原来是一只小松鼠。

三级标题

这是一个 blockquote。

这是引用区块的第二段。

这是一个 blockquote 中的 H2

短语的强调

Markdown 是用星号和下划线来表示强调。

Markdown:

这里有些词*应被强调*。
这里也有些词_应被强调_。
两个星号代表的是**特别强调**。
或者,如果你喜欢的话,__用两个下划线也可以__。

输出:

这里有些词应被强调
这里也有些词应被强调

两个星号代表的是特别强调.
或者,如果你喜欢的话,用两个下划线也可以

列表

无序列表 (通常用圆点开头的那种) 可以用星号、加号或连字符 (*, +, 或 -) 作为列表项的起始符。这些符号都是可以互换的,比如说这个:

* 小驴叔叔
* 老牛伯伯
* 小松鼠

这个:

+ 小驴叔叔
+ 老牛伯伯
+ 小松鼠

与这个:

- 小驴叔叔
- 老牛伯伯
- 小松鼠

都将生成相同的输出:

  • 小驴叔叔
  • 老牛伯伯
  • 小松鼠

有序列表则是用常规的数字带小数点 (.) 表示的:

1. 小驴叔叔
2. 老牛伯伯
3. 小松鼠

输出:

  1. 小驴叔叔
  2. 老牛伯伯
  3. 小松鼠

不过,如果你在列表项之间放置了空行,列表项中的文本会被

包含。而这些段落之前若用 4 个空格或者 1 个 tab 缩进的话,就能获得具有多个段落的列表项。

* 一个列表项。
具有多个段落。
* 同一个列表中的又一项。

输出:

  • 一个列表项。

    具有多个段落。

  • 同一个列表中的又一项。

链接

Markdown 支持两种创建链接的方法:行内式和引用式。这两种方法都需要你用方括号包围希望转换为链接的文本。

行内风格的链接是在链接文本后面用圆括号直接包含链接地址。例如:

这是一个[示例链接](http://example.com/)。

输出:

这是一个
示例链接

你还能给它添加一个可选的标题属性:

这是一个[示例链接](http://example.com/ "且有个标题")。

输出:

这是一个
示例链接

引用风格的链接允许你通过命名来指定链接,只要你在文档的其他地方定义好这个“名称”到“地址”的对应。

来自 [Google][1] 的访问足有来自 [Yahoo][2] 或 [MSN][3] 的 10
倍之多。
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"

输出:

来自 Google
的访问足有来自 title="Yahoo Search">Yahoo title="MSN Search">MSN 的 10 倍之多。

标题属性是可选的。链接的名字允许包含字母、数字与空格,但忽略大小写。

我的早晨始于一杯咖啡与一份[纽约时报][NY Times].
[ny times]: http://www.nytimes.com/

输出:

我的早晨始于一杯咖啡与一份
纽约时报

图像

图像的语法与链接的语法很类似。

行内风格 (标题 (title) 是可选的):

![alt text](/path/to/img.jpg "标题")

引用风格:

![alt text][id]
[id]: /path/to/img.jpg "标题"

上面两个例子都会产生同样的输出:

alt text

代码

在段落中,反引号可以用来标识代码,在反引号包围中的 & 和尖括号 (< 或 >) 都会被自动的转换为 HTML 实体。这样一来,用 Markdown 写关于 HTML 的代码就会容易一些:

我强烈反对使用任何 <‘ blink ’> 标记。
我希望 SmartyPants 用 `—` 这样的命名实体来代替
`—` 这样的 10 进制编码的实体。

输出:

我强烈反对使用任何
<‘ blink ’> “标记。

我希望 SmartyPants 用 &mdash;
这样的命名实体来代替 &#8212; 这样的
10 进制编码的实体。

要指定一整块预先格式化好的代码,你必须把其中每行都用 4 个空格或者 1 个 tab 缩进。就像在行内的代码一样,&, < 和 > 字符都会被自动转换妥当。

Markdown:

倘若你希望你的页面通过 XHTML 1.0 Strict 的验证,
就必须在 blockquotes 中加入段落标记:

就像这样。

输出:

倘若你希望你的页面通过 XHTML 1.0 Strict 的验证,
就必须在 blockquotes 中加入段落标记:

<blockquote>
<p>就像这样。</p>
</blockquote>

Markdown 测试

Markdown 测试


测试标题

你可以用Markdown 语法来改变文字页地址和电邮地址会被自动转换成连结页地址和电邮地址会被自动转换成连结的格式。

  • 页地址和电邮地址会被自动转换成连结
  • 页地址和电邮地址会被自动转换地址会被自动

    转换地址会被自动转换地址会被自动转换地址会被自动转换地址会被自动转换动转换动转换成连结 转换地址会被自动转换地址会被自动转换

    转换地址会被自动转换地址会被自动转换地址会被自动转换地址会被自动转换动转换动转换成连结

  • 页地址和电邮地址会被自动转换成动转换动转换动转换动转换动转换连结


下面是代码页面

页地址和电邮地址会被自动转换成连结
页地址和电邮地址会被自动转换成连结

SmartyPants Help

Version 1.5.1e - Fri 9 Dec 2005

by Michel Fortin

based on work by John Gruber

Introduction
------------

PHP SmartyPants is a port to PHP of the original SmartyPants written
in Perl by John Gruber.

PHP SmartyPants is a free web publishing plug-in for WordPress and
Smarty template engine that easily translates plain ASCII punctuation
characters into "smart" typographic punctuation HTML entities.
SmartyPants can also be invoked as a standalone PHP function.

SmartyPants can perform the following transformations:

* Straight quotes (`"` and `'`) into "curly" quote HTML entities
* Backtick-style quotes (` ``like this'' `) into "curly" quote HTML
entities
* Dashes (`--` and `---`) into en- and em-dash entities
* Three consecutive dots (`...`) into an ellipsis entity

This means you can write, edit, and save using plain old ASCII straight
quotes, plain dashes, and plain dots, but your published posts (and
final HTML output) will appear with smart quotes, em-dashes, and proper
ellipses.

SmartyPants does not modify characters within `

`, ``,
``, or `<script>` tag blocks. Typically, these tags are used to
display text where smart quotes and other "smart punctuation" would not
be appropriate, such as source code or example markup.

### Backslash Escapes ###

If you need to use literal straight quotes (or plain hyphens and
periods), SmartyPants accepts the following backslash escape sequences
to force non-smart punctuation. It does so by transforming the escape
sequence into a decimal-encoded HTML entity:

Escape Value Character
------ ----- ---------
\\ \ \
\" " "
\' ' '
\. . .
\- - -
\` ` `

This is useful, for example, when you want to use straight quotes as
foot and inch marks:

6\'2\" tall

translates into:

6'2" tall

in SmartyPants's HTML output. Which, when rendered by a web browser,
looks like:

6'2" tall

Installation and Requirement
----------------------------

PHP SmartyPants require PHP version 4.0.5 or later.

### WordPress ###

WordPress already include a filter called "Texturize" with the same
goal as SmartyPants. You could still find some usefulness to
PHP SmartyPants if you are not happy enough with the standard algorithm.

PHP SmartyPants works with [WordPress][wp], version 1.2 or later.

[wp]: http://wordpress.org/

1. To use PHP SmartyPants with WordPress, place the "smartypants.php"
file in the "plugins" folder. This folder is hidden inside
"wp-content" at the root of your site:

(site home)/wp-content/plugins/smartypants.php

2. Activate the plugin with the administrative interface of WordPress.
In the "Plugins" section you will now find SmartyPants. To activate
the plugin, click on the "Activate" button on the same line than
SmartyPants. Your entries will now be filtered by PHP SmartyPants.

Note: It is not possible at this time to apply a different set of
filters to different entries. All your entries will be filtered by
PHP SmartyPants if the plugin is active. This is currently a limitation
of WordPress.

### Blosxom ###

SmartyPants works with Blosxom version 2.0 or later.

1. Rename the "SmartyPants.pl" plug-in to "SmartyPants" (case is
important). Movable Type requires plug-ins to have a ".pl"
extension; Blosxom forbids it (at least as of this writing).

2. Copy the "SmartyPants" plug-in file to your Blosxom plug-ins folder.
If you're not sure where your Blosxom plug-ins folder is, see the
Blosxom documentation for information.

3. That's it. The entries in your weblog should now automatically have
SmartyPants's default transformations applied.

4. If you wish to configure SmartyPants's behavior, open the
"SmartyPants" plug-in, and edit the value of the `$smartypants_attr`
configuration variable, located near the top of the script. The
default value is 1; see "Options", below, for the full list of
supported values.

### In your programs ###

You can use PHP SmartyPants easily in your current PHP program. Simply
include the file and then call the `SmartyPants` function on the text
you want to convert:

include_once "smartypants.php";
$my_text = SmartyPants($my_text);

### With Smarty ###

If your program use the [Smarty][sm] template engine, PHP SmartyPants
can now be used as a modifier for your templates. Rename
"smartypants.php" to "modifier.smartypants.php" and put it in your
smarty plugins folder.

[sm]: http://smarty.php.net/

Options and Configuration
-------------------------

Settings are specified by editing the value of the `$smartypants_attr`
variable in the "smartypants.php" file. For users of the Smarty template
engine, the "smartypants" modifier also takes an optional attribute where
you can specify configuration options, like this:
`{$var|smartypants:1}` (where "1" is the configuration option).

Numeric values are the easiest way to configure SmartyPants's behavior:

"0"
Suppress all transformations. (Do nothing.)

"1"
Performs default SmartyPants transformations: quotes (including
backticks-style), em-dashes, and ellipses. `--` (dash dash) is
used to signify an em-dash; there is no support for en-dashes.

"2"
Same as smarty_pants="1", except that it uses the old-school
typewriter shorthand for dashes: `--` (dash dash) for en-dashes,
`---` (dash dash dash) for em-dashes.

"3"
Same as smarty_pants="2", but inverts the shorthand for dashes: `--`
(dash dash) for em-dashes, and `---` (dash dash dash) for en-dashes.

"-1"
Stupefy mode. Reverses the SmartyPants transformation process,
turning the HTML entities produced by SmartyPants into their ASCII
equivalents. E.g. `“` is turned into a simple double-quote
(`"`), `—` is turned into two dashes, etc. This is useful if you
wish to suppress smart punctuation in specific pages, such as
RSS feeds.

The following single-character attribute values can be combined to
toggle individual transformations from within the smarty_pants
attribute. For example, to educate normal quotes and em-dashes, but not
ellipses or backticks-style quotes:

$smartypants_attr = "qd";

Or inside a Smarty template:

{$var|smartypants:"qd"}

"q"
Educates normal quote characters: (`"`) and (`'`).

"b"
Educates ` ``backticks'' ` double quotes.

"B"
Educates backticks-style double quotes and ` `single' ` quotes.

"d"
Educates em-dashes.

"D"
Educates em-dashes and en-dashes, using old-school typewriter
shorthand: (dash dash) for en-dashes, (dash dash dash) for
em-dashes.

"i"
Educates em-dashes and en-dashes, using inverted old-school
typewriter shorthand: (dash dash) for em-dashes, (dash dash dash)
for en-dashes.

"e"
Educates ellipses.

"w"
Translates any instance of `"` into a normal double-quote
character. This should be of no interest to most people, but of
particular interest to anyone who writes their posts using
Dreamweaver, as Dreamweaver inexplicably uses this entity to
represent a literal double-quote character. SmartyPants only
educates normal quotes, not entities (because ordinarily, entities
are used for the explicit purpose of representing the specific
character they represent). The "w" option must be used in
conjunction with one (or both) of the other quote options ("q" or
"b"). Thus, if you wish to apply all SmartyPants transformations
(quotes, en- and em-dashes, and ellipses) and also translate
`"` entities into regular quotes so SmartyPants can educate
them, you should pass the following to the smarty_pants attribute:

$smartypants_attr = "qDew";

Inside a Smarty template, this will be:

{$var|smartypants:"qDew"}

Caveats
-------

### Why You Might Not Want to Use Smart Quotes in Your Weblog ###

For one thing, you might not care.

Most normal, mentally stable individuals do not take notice of proper
typographic punctuation. Many design and typography nerds, however,
break out in a nasty rash when they encounter, say, a restaurant sign
that uses a straight apostrophe to spell "Joe's".

If you're the sort of person who just doesn't care, you might well want
to continue not caring. Using straight quotes -- and sticking to the
7-bit ASCII character set in general -- is certainly a simpler way to
live.

Even if you *do* care about accurate typography, you still might want to
think twice before educating the quote characters in your weblog. One
side effect of publishing curly quote HTML entities is that it makes
your weblog a bit harder for others to quote from using copy-and-paste.
What happens is that when someone copies text from your blog, the copied
text contains the 8-bit curly quote characters (as well as the 8-bit
characters for em-dashes and ellipses, if you use these options). These
characters are not standard across different text encoding methods,
which is why they need to be encoded as HTML entities.

People copying text from your weblog, however, may not notice that
you're using curly quotes, and they'll go ahead and paste the unencoded
8-bit characters copied from their browser into an email message or
their own weblog. When pasted as raw "smart quotes", these characters
are likely to get mangled beyond recognition.

That said, my own opinion is that any decent text editor or email client
makes it easy to stupefy smart quote characters into their 7-bit
equivalents, and I don't consider it my problem if you're using an
indecent text editor or email client.

### Algorithmic Shortcomings ###

One situation in which quotes will get curled the wrong way is when
apostrophes are used at the start of leading contractions. For example:

'Twas the night before Christmas.

In the case above, SmartyPants will turn the apostrophe into an opening
single-quote, when in fact it should be a closing one. I don't think
this problem can be solved in the general case -- every word processor
I've tried gets this wrong as well. In such cases, it's best to use the
proper HTML entity for closing single-quotes (`’` or `’`) by
hand.

Bugs
----

To file bug reports or feature requests (other than topics listed in the
Caveats section above) please send email to:

If the bug involves quotes being curled the wrong way, please send
example text to illustrate.

Version History
---------------

1.5.1e (9 Dec 2005)

* Corrected a bug that prevented special characters from being
escaped.

1.5.1d (6 Jun 2005)

* Correct a small bug in `_TokenizeHTML` where a Doctype declaration
was not seen as HTML, making curly quotes inside it.

1.5.1c (13 Dec 2004)

* Changed a regular expression in `_TokenizeHTML` that could lead
to a segmentation fault with PHP 4.3.8 on Linux.

1.5.1b (6 Sep 2004)

* Corrected a problem with quotes immediately following a dash
with no space between: `Text--"quoted text"--text.`

* PHP SmartyPants can now be used as a modifier by the Smarty
template engine. Rename the file to "modifier.smartypants.php"
and put it in your smarty plugins folder.

* Replaced a lot of spaces characters by tabs, saving about 4 KB.

1.5.1a (30 Jun 2004)

* PHP Markdown and PHP Smartypants now share the same `_TokenizeHTML`
function when loaded simultanously.

* Changed the internals of `_TokenizeHTML` to lower the PHP version
requirement to PHP 4.0.5.

1.5.1 (6 Jun 2004)

* Initial release of PHP SmartyPants, based on version 1.5.1 of the
original SmartyPants written in Perl.

Copyright and License
---------------------

Copyright (c) 2005 Michel Fortin

All rights reserved.

Copyright (c) 2003-2004 John Gruber

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name "SmartyPants" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.