Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Cn-cuckoo/撰写说明

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.
原文链接:Help:Editing

撰写说明

WordPress Codex中的样式约定与其他Wiki不同。要了解详细的样式规范,请参阅Codex:Styles。下列与撰写新文章有关的样式和标记涵盖了Codex中的具体样式,也包含来自MediaWiki's Guide: Editing Overview的建议和结构规范。要了解在页面中使用样式的更多信息,请参考:


In the chart below, in the left column of the table below, you can see what effects are possible. In the right column, you can see how those effects were achieved. In other words, to make text look like it looks in the left column, type it in the format you see in the right column.

You may want to keep this page open in a separate browser window for reference. If you want to try out things without danger of doing any harm, you can do so in the Sandbox.

小节、段落、列表和换行

要知道小节标题是什么样式,请参考本页中的小节。

要生成各级小节标题,需要输入:

== 新小节 ==

=== 新二级小节 ===

==== 新三级小节 ====

换行

要在文本中强制换行,可以使用XHTML标签<br/>。例如:

我打算在这里强制换行,<br />
看,这半句被换到了下一行。

得到的结果如下:

我打算在这里强制换行,
看,这半句被换到了下一行。

如果想生成一个新段落,则有两种方式:

  1. 在文本结尾回两次车,即让上一段最后一行与下一段第一行间产生一个空行
  2. 使用XHTML标签<p>和<p/>包装每个段落

例如,代码:

这是第一段。

这是第二段。

<p>这是第一段。<p/>
<p>这是第二段。<p/>

都会生成如下结果:

这是第一段。

这是第二段。

列表

  • Lists are easy to do:
    • start every line with a star
      • more stars means deeper levels
  • A newline
  • in a list

marks the end of the list.

  • Of course
  • you can
  • start again.
* Lists are easy to do:
** start every line with a star
*** more stars means deeper levels
*A newline
*in a list  
marks the end of the list.
*Of course
*you can
*start again.
  1. Numbered lists are also good
    1. very organized
    2. easy to follow
  2. A newline
  3. in a list

marks the end of the list.

  1. New numbering starts
  2. with 1.
# Numbered lists are also good
## very organized
## easy to follow
#A newline
#in a list  
marks the end of the list.
#New numbering starts
#with 1.
  • You can even do mixed lists
    1. and nest them
      • like this
        or have newlines
        inside lists
* You can even do mixed lists
*# and nest them
*#* like this<br />or have newlines<br />inside lists
  • You can also
    • break lines
      inside lists
      like this
* You can also
**break lines<br />inside lists<br />like this
Definition list 
list of definitions
item 
the item's definition
; Definition list : list of definitions
; item : the item's definition

Indents

NOTE: Indents are currently not working in the WordPress Codex styles. Indent when appropriate and this should be resolved soon.

A colon indents a line or paragraph.

A manual newline starts a new paragraph.

  • This is primarily for displayed material, but is also used for discussion on Talk pages.
: A colon indents a line or paragraph.
A manual newline starts a new paragraph.
IF a line of plain text starts with a space THEN
  it will be formatted exactly
    as typed;
  in a fixed-width font;
  lines won't wrap;
ENDIF
this is useful for:
  * pasting preformatted text;
  * algorithm descriptions;
  * program source code
  * ASCII art;
  * chemical structures;

Centered text

NOTE: Centered Texts are currently not working in the WordPress Codex styles. Center when appropriate and this should be resolved soon.

To center text, use the <center> HTML tag.
<center>Centered text.</center>

Horizontal Line

NOTE: Horizontal Lines are currently not working in the WordPress Codex styles. Add the lines when appropriate and this should be resolved soon.

A horizontal dividing line: above


and below.

In most cases a section header is more useful. The horizontal dividing line should only be used if what follows is logically part of the same section; otherwise that part would be hidden in the TOC.

A horizontal dividing line: above
----
and below. 

Links, URLs

Sue is reading about the WordPress_Features.

  • First letter of target is automatically capitalized.
  • Internally spaces are automatically represented as underscores (typing an underscore has the same effect as typing a space, but is not recommended).

Thus the link above is to http://codex.wordpress.org/WordPress_Features, which is the page with the name "WordPress Features".

Sue is reading about the [[WordPress_Features]].

When linking to another WordPress Codex page, the link does not need the underline in between the words:

[[WordPress Features]]

When linking to a WordPress Codex page from an external source, such as a blog, the underline is required.

To link to a section on a page, e.g. List_of_cities_by_country#Morocco; when section linking does not work the link is treated as link to the page, i.e. to the top; this applies for:

  • links to non-existent sections
  • links in redirects
  • interwiki links
[[List_of_cities_by_country#Morocco]].

It is recommended to reword the links when the link target and link label are different, such as linking to a seciton of linking from within the context of the article.

For example, you might want to link to a list of cities by country for Morocco.

...you might want to link to 
[[List_of_cities_by_country#Morocco|a list of cities by country for Morocco]].

A piped link is when you link to a target and the link label is different: For example, you want to link to the features of WordPress.

Same target, different name: [[WordPress Features|the features of WordPress]]

Endings are blended into the link: official positions, genes

Endings are blended
into the link: [[official position]]s, [[gene]]s

Automatically hide stuff in parentheses: kingdom.

Automatically hide namespace: Village pump.

The server fills in the part after the | when you save the page. Next time you open the edit box you will see the expanded piped link. A preview interprets the abbreviated form correctly, but does not expand it yet in the edit box. Press Save and again Edit, and you will see the expanded version. The same applies for the following feature.

Automatically hide stuff in parentheses:
[[kingdom (biology)|]]. 
Automatically hide namespace:
[[Wikipedia:Village pump|]].

Direct to Another Codex Page

A link to the page on the same subject in another language or, more generally, to a page on another wiki: fr:Wikipédia:Aide. For more info see m:Help:Interwiki linking.

[[fr:Wikipédia:Aide]], [[:fr:Wikipédia:Aide]]

"What links here" and "Related changes" can be linked as:
Special:Whatlinkshere/Wikipedia:How to edit a page and Special:Recentchangeslinked/Wikipedia:How to edit a page

[[Special:Whatlinkshere/
Wikipedia:How to edit a page]] and
[[Special:Recentchangeslinked/
Wikipedia:How to edit a page]]

To make these links more user friendly, use piped links:

"What links here" and "Related changes" can be linked as:
Wikipedia:How to edit a page and Wikipedia:How to edit a page

[[Special:Whatlinkshere/Wikipedia:How to edit a 
page|Wikipedia:How to edit a page]] and
[[Special:Recentchangeslinked/Wikipedia:How to 
edit a page|Wikipedia:How to edit a page]]

External Links

External links are set with one bracket and a space between the URL and the link title as: WordPress.

External links:
[http://www.wordpress.org WordPress]

Or just give the URL: http://www.wordpress.org if it is very short.

Or just give the URL: http://www.wordpress.org if it is very short.
  • In the URL all symbols must be among: A-Z a-z 0-9 ._\/~%-+&#?!=()@ \x80-\xFF. If a URL contains a different character it should be converted; for example, ^ has to be written %5E (to be looked up in ASCII). A blank space can also be converted into an underscore.

To link to books, you can use ISBN links. ISBN 0123456789X See Help:ISBN links

ISBN 0123456789X

Link to Request for Comments: RFC 123 (URL specified in mediawiki:Rfcurl)

Link to [[w:Request for Comments|Request for Comments]]: RFC 123 
(URL specified in [[mediawiki:Rfcurl]])

Red Links to Pages That Don't Exist

The weather in London is a page that doesn't exist yet. If you know the page exists, double check the link to ensure that it is spelled correctly. Do not create a new page to one that already exists.

  • You can create it by clicking on the link.
  • To create a new page:
    1. Create a link to it on some other page.
    2. Save that page.
    3. Click on the link you just made. The new page will open for editing.
  • Have a look at how to start a page guide and the naming conventions page for your project.
[[The weather in London]] is a page that doesn't exist yet.

Images and Multimedia

The WordPress Codex allows links to uploaded images and multimedia files, as well as links to external multimedia files, though these are not recommended. Copyrights are to be protected at all times and copyrighted images and content are not allowed on the WordPress Codex without explicit permission of the owner.

Pictures and Images

A picture: WordPress Codex Logo

  • To upload images, use the upload page. You can find the uploaded image on the image list
  • For layout purposes, you can align the image and have it be thumbnail sized so the user can click the image to see a larger version:
WordPress Default Theme
[[Image:Kubrick_Single.jpg|left|thumbnail|WordPress Default Theme]]
A picture: [[Image:codex-logo-2.png|WordPress Codex Logo]]

The alternate text is required.

[[Image:codex-logo-2.png|WordPress Codex Logo]]

Web browsers render alternate text when not displaying an image -- for example, when the image isn't loaded, or in a text-only browser, or when spoken aloud. See Alternate text for images for help on choosing alternate text. See Extended image syntax for more image options.

NOTE: Currently, right and left floats do not work in the current Codex styles. Hopefully this will be fixed soon, so code for the floats as you edit.

To float the full-size image to the right or left of the text, use:

[[Image:codex-logo-2.png|right|WordPress Codex Logo]]

For right float thumbnail image:

[[Image:codex-logo-2.png|right|thumbnail|WordPress Codex Logo]]

For left float thumbnail image:

[[Image:codex-logo-2.png|left|thumbnail|WordPress Codex Logo]]

Clicking on an uploaded image displays the image on a blank page, which you can also link directly to: Image:codex-logo-2.png

[[:Image:codex-logo-2.png]]

Links to Multimedia

To include links to images shown as links instead of drawn on the page, use a "media" link.
WordPress Square Logo

[[media:wpsqlogo.png|WordPress Square Logo]]

To include links to non-image uploads such as sounds, use a "media" link.
Sound of turtles

[[media:Sg_mrob.ogg|Sound of turtles]]

Character Formatting

Emphasize, strongly, very strongly.

  • These are double and triple apostrophes, not double quotes.
''Emphasize'', '''strongly''',
'''''very strongly'''''.

You can also write italic and bold if the desired effect is a specific font style rather than emphasis, as in mathematical formulas:

F = ma
  • However, the difference between these two methods is not very important for graphical browsers, and many people choose to ignore it.
You can also write <i>italic</i>
and <b>bold</b> if the desired effect is a 
specific font style rather than emphasis, as 
in math formulas:
:<b>F</b> = <i>m</i><b>a</b>

Use the typewriter font for technical terms and references.

A typewriter font for 
<tt>technical terms</tt>.

You can use small text for captions.

You can use <small>small text</small> for captions.

You can strike out deleted material and underline new material.

You can <strike>strike out deleted material</strike> 
and <u>underline new material</u>.

Talk Page Editing Options

When adding a comment to a Talk page, you should sign it. You can do this by adding three tildes for your user name:

Karl Wick

or four for user name plus date/time:

Karl Wick 08:10 Oct 5, 2002 (UTC)
When adding a comment to a Talk page,
you should sign it. You can do this by
adding three tildes for your user name:
: ~~~
or four for user name plus date/time:
: ~~~~

Language Specific Edits

Umlauts and accents

(See MediaWiki's User Guide: Creating special characters])
è é ê ë ì í

À Á Â Ã Ä Å
Æ Ç È É Ê Ë
Ì Í Î Ï Ñ Ò
Ó Ô Õ Ö Ø Ù
Ú Û Ü ß à á
â ã ä å æ ç
è é ê ë ì í
î ï ñ ò ó ô
œ õ ö ø ù ú
û ü ÿ

è é ê ë ì í

&Agrave; &Aacute; &Acirc; &Atilde; &Auml; &Aring;
&AElig; &Ccedil; &Egrave; &Eacute; &Ecirc; &Euml;
&Igrave; &Iacute; &Icirc; &Iuml; &Ntilde; &Ograve;
&Oacute; &Ocirc; &Otilde; &Ouml; &Oslash; &Ugrave;
&Uacute; &Ucirc; &Uuml; &szlig; &agrave; &aacute;
&acirc; &atilde; &auml; &aring; &aelig; &ccedil;
&egrave; &eacute; &ecirc; &euml; &igrave; &iacute;
&icirc; &iuml; &ntilde; &ograve; &oacute; &ocirc;
&oelig; &otilde; &ouml; &oslash; &ugrave; &uacute;
&ucirc; &uuml; &yuml;

Punctuation

¿ ¡ « » § ¶
† ‡ • - – —

&iquest; &iexcl; &laquo; &raquo; &sect; &para;
&dagger; &Dagger; &bull; - &ndash; &mdash;

Commercial symbols

™ © ® ¢ € ¥
£ ¤

&trade; &copy; &reg; &cent; &euro; &yen;
&pound; &curren;

Subscript: x2

Superscript: x2 or x²

  • The latter method of superscript can't be used in the most general context, but is preferred when possible (as with units of measurement) because most browsers have an easier time formatting lines with it.

ε0 = 8.85 × 10−12 C² / J m.

1 hectare = 1 E4 m²

Subscript: x<sub>2</sub>
Superscript: x<sup>2</sup> or x&sup2;

or in projects with the templates sub and sup:

Subscript: x{{sub|2}}
Superscript: x{{sup|2}}

&epsilon;<sub>0</sub> =
8.85 &times; 10<sup>&minus;12</sup>
C&sup2; / J m.

1 [[hectare]] = [[1 E4 m²]]

Greek characters

α β γ δ ε ζ
η θ ι κ λ μ ν
ξ ο π ρ σ ς
τ υ φ χ ψ ω
Γ Δ Θ Λ Ξ Π
Σ Φ Ψ Ω

&alpha; &beta; &gamma; &delta; &epsilon; &zeta;
&eta; &theta; &iota; &kappa; &lambda; &mu; &nu;
&xi; &omicron; &pi; &rho;  &sigma; &sigmaf;
&tau; &upsilon; &phi; &chi; &psi; &omega;
&Gamma; &Delta; &Theta; &Lambda; &Xi; &Pi;
&Sigma; &Phi; &Psi; &Omega;

Math characters

∫ ∑ ∏ √ − ± ∞
≈ ∝ ≡ ≠ ≤ ≥
× · ÷ ∂ ′ ″
∇ ‰ ° ∴ ℵ ø
∈ ∉ ∩ ∪ ⊂ ⊃ ⊆ ⊇
¬ ∧ ∨ ∃ ∀ ⇒ ⇔
→ ↔ ↑

&int; &sum; &prod; &radic; &minus; &plusmn; &infin;
&asymp; &prop; &equiv; &ne; &le; &ge; 
&times; &middot; &divide; &part; &prime; &Prime;
&nabla; &permil; &deg; &there4; &alefsym; &oslash;
&isin; &notin; &cap; &cup; &sub; &sup; &sube; &supe;
&not; &and; &or; &exist; &forall; &rArr; &hArr;
&rarr; &harr; &uarr;

x2   ≥   0 true.

  • To space things out, use non-breaking spaces - &nbsp;.
  • &nbsp; also prevents line breaks in the middle of text, this is useful in formulas.
<i>x</i><sup>2</sup>&nbsp;&nbsp;&ge;&nbsp;&nbsp;0 true.

Complicated formulae

  <math>\sum_{n=0}^\infty \frac{x^n}{n!}</math>

<math>\sum_{n=0}^\infty \frac{x^n}{n!}</math>

For comparison for the following examples:

arrow →

arrow      &rarr;

Nowiki: Suppressing Wiki Markup

Use <nowiki> to suppress interpretation of wiki markup, but interpret character references and remove newlines and multiple spaces:

arrow →

<nowiki>arrow      &rarr;
</nowiki>

Using PRE for Code

Use <pre> to suppress interpretation of wiki markup and keep newlines and multiple spaces, and get typewriter font, but interpret character references:

arrow      →
<pre>arrow      &rarr;
</pre>

The same PRE effect can be used with the leading space shortcut. Use leading space on each line to keep newlines and multiple spaces, and get typewriter font:

arrow      →
arrow      &rarr;

Use <tt> to format for typewriter font:

arrow →

<tt>arrow      &rarr;</tt>

Show Character References

To show character references or extended characters on a page, convert the ampersand and hash or pound signs into extended characters. See Writing and Publishing Code in Your WordPress Blog Posts for tips.

&rarr;

&amp;rarr;

Other Editing Details

HTML Tables

HTML tables can be quite useful as well. For details on how to use them and discussion about when they are appropriate, see MediaWiki User's Guide: Using tables.

NOTE: Currently, spacing within tables and some table styles are not working. Hopefully, this will be resolved soon.

Table of Contents

By default, the table of contents on a page is generated at the first section heading. Since this might be low down on the page, it is recommended to force the table of contents to appear at the top of the page by typing the following at the top of the page.

__TOC__

Commenting page source

To leave a comment on a page for future editors, use the HTML comment tag to hide the note:

<!-- comment here -->

Separating Edits

When moving or copying a piece of text within a page or from another page, and also making other edits, it is useful to separate these edits. This way the diff function can be usefully applied for checking these other edits.

Administrator Notes and Edit Capabilities

Redirect Page Links

Redirect one article title to another by putting text like this in its first line.

#REDIRECT [[United States]]

Usage restricted to only the admins on the WordPress Codex.

Templates

Some text on a page may correspond in the edit box to just a reference to another page, in the form {{name}}, referring to the page "Template:name". This is called a template. For changing that text, edit that other page. Sometimes a separate edit link is provided for this purpose. A convenient way to put such a link in a template in Wikipedia is with en:Template:ed.

Page protection

In a few cases the link labeled "Edit this page" is replaced by the text "Protected page" (or equivalents in the language of the project). In that case the page can not be edited.Cn-cuckoo 08:34, 27 January 2009 (UTC)