none
[openafs-wiki.git] / TWiki / TextFormattingRules.mdwn
1 <div>
2   <ul>
3     <li><a href="#TWiki Text Formatting"> TWiki Text Formatting</a><ul>
4         <li><a href="#TWiki Editing Shorthand"> TWiki Editing Shorthand</a></li>
5         <li><a href="#Using HTML"> Using HTML</a><ul>
6             <li><a href="#HTML and TWiki Usability"> HTML and TWiki Usability</a></li>
7             <li><a href="#TWiki HTML Rendering"> TWiki HTML Rendering</a></li>
8           </ul>
9         </li>
10         <li><a href="#Hyperlinks"> Hyperlinks</a><ul>
11             <li><a href="#Internal Links"> Internal Links</a></li>
12             <li><a href="#External Links"> External Links</a></li>
13           </ul>
14         </li>
15         <li><a href="#TWiki Variables"> TWiki Variables</a></li>
16         <li><a href="#TWikiPlugin Formatting Extension"> TWikiPlugin Formatting Extensions</a></li>
17         <li><a href="#Common Editing Errors"> Common Editing Errors</a></li>
18       </ul>
19     </li>
20   </ul>
21 </div>
22
23 # <a name="TWiki Text Formatting"></a> TWiki Text Formatting
24
25 Working in TWiki is as easy as typing in text - exactly like email. You don't need to know HTML, though you can use it if you prefer. Links to topics are created automatically when you enter [[WikiWords]]. And TWiki shorthand gives you all the power of HTML with a simple coding system that takes no time to learn. It's all layed out below - refer back to this page in a pop-up window from the **Edit** screen.
26
27 <a name="TWikiShorthand"></a>
28
29 ## <a name="TWiki Editing Shorthand"></a> TWiki Editing Shorthand
30
31 <table bgcolor="#000000" border="0" cellpadding="3" cellspacing="1">
32   <tr bgcolor="#ffffff">
33     <td><strong>Formatting Command:</strong></td>
34     <td><strong>Example: You write:</strong></td>
35     <td><strong>You get:</strong></td>
36   </tr>
37   <tr bgcolor="#ffffff">
38     <td valign="top"><strong>Paragraphs:</strong><br /> Blank lines will create new paragraphs. </td>
39     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
40 1st paragraph
41
42 2nd paragraph
43 </pre> </font></span></td>
44     <td valign="top"> 1st paragraph <p> 2nd paragraph </p>
45     </td>
46   </tr>
47   <tr bgcolor="#ffffff">
48     <td valign="top"><strong>Headings:</strong><br /> At least three dashes at the beginning of a line, followed by plus signs and the heading text. One plus creates a level 1 heading (most important), two pluses a level 2 heading; the maximum is level 6. <strong><em>Note:</em></strong> A Table of Content can be created automatically with the <code>%TOC%</code> variable, see [[Main/TWikiVariables]]. Any heading text after <code>!!</code> is excluded from the TOC; for example, write <code>---+!! text</code> if you do not want to list a header in the TOC. </td>
49     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
50 ---++ Sushi
51
52 ---+++ Maguro
53 </pre> </font></span></td>
54     <td valign="top">
55       <h2>Sushi</h2>
56       <p>
57       </p>
58       <h3>Maguro</h3>
59     </td>
60   </tr>
61   <tr bgcolor="#ffffff">
62     <td valign="top"><strong>Bold Text:</strong><br /> Words get <strong>bold</strong> by enclosing them in <code>*</code> asterisks. </td>
63     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
64 *Bold*
65 </pre> </font></span></td>
66     <td valign="top"><strong>Bold</strong></td>
67   </tr>
68   <tr bgcolor="#ffffff">
69     <td valign="top"><strong>Italic Text:</strong><br /> Words get <em>italic</em> by enclosing them in <code>_</code> underscores. </td>
70     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
71 _Italic_
72 </pre> </font></span></td>
73     <td valign="top"><em>Italic</em></td>
74   </tr>
75   <tr bgcolor="#ffffff">
76     <td valign="top"><strong>Bold Italic:</strong><br /> Words get <em>_bold italic</em> by enclosing them in <code>_</code> double-underscores. </td>
77     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
78 __Bold italic__
79 </pre> </font></span></td>
80     <td valign="top"><strong><em>Bold italic</em></strong></td>
81   </tr>
82   <tr bgcolor="#ffffff">
83     <td valign="top"><strong>Fixed Font:</strong><br /> Words get shown in <code>fixed font</code> by enclosing them in <code>=</code> equal signs. </td>
84     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
85 =Fixed font=
86 </pre> </font></span></td>
87     <td valign="top"><code>Fixed font</code></td>
88   </tr>
89   <tr bgcolor="#ffffff">
90     <td valign="top"><strong>Bold Fixed Font:</strong><br /> Words get shown in <code><b>bold fixed font</b></code> by enclosing them in <code><b></b></code> double equal signs. </td>
91     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
92 ==Bold fixed==
93 </pre> </font></span></td>
94     <td valign="top"><code><b>Bold fixed</b></code></td>
95   </tr>
96   <tr bgcolor="#ffffff">
97     <td valign="top"><strong><em>Note:</em></strong> Make sure to "stick" the <code>* _ = ==</code> signs to the words, e.g. take away spaces. </td>
98     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
99 _This works_,
100 _this not _
101 </pre> </font></span></td>
102     <td valign="top"><em>This works</em>, _this not _ </td>
103   </tr>
104   <tr bgcolor="#ffffff">
105     <td valign="top"><strong>Verbatim Mode:</strong><br /> Surround code excerpts and other formatted text with <code>&lt;verbatim&gt;</code> and <code>&lt;/verbatim&gt;</code> tags. <br /><strong><em>Note:</em></strong> Use <code>&lt;pre&gt;</code> and <code>&lt;/pre&gt;</code> tags instead if you want that HTML code is interpreted. <br /><strong><em>Note:</em></strong> Each tag must be on a line by itself. </td>
106     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
107 &lt;verbatim&gt;
108 class CatAnimal {
109   void purr() {
110          &lt;code here&gt;
111   }
112 }
113 &lt;/verbatim&gt;
114 </pre> </font></span></td>
115     <td valign="top"><pre>
116 class CatAnimal {
117   void purr() {
118     &lt;code here&gt;
119   }
120 }
121 </pre></td>
122   </tr>
123   <tr bgcolor="#ffffff">
124     <td valign="top"><strong>Separator:</strong><br /> At least three dashes at the beginning of a line. </td>
125     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
126 -------
127 </pre> </font></span></td>
128     <td valign="top">
129       <hr />
130     </td>
131   </tr>
132   <tr bgcolor="#ffffff">
133     <td valign="top"><strong>List Item:</strong><br /> Three spaces and an asterisk. </td>
134     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
135         * bullet item
136 </pre> </font></span></td>
137     <td valign="top">
138       <ul>
139         <li> bullet item </li>
140       </ul>
141     </td>
142   </tr>
143   <tr bgcolor="#ffffff">
144     <td valign="top"><strong>Nested List Item:</strong><br /> Six, nine, ... spaces and an asterisk. </td>
145     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
146                 * nested stuff
147 </pre> </font></span></td>
148     <td valign="top">
149       <ul>
150         <li>
151           <ul>
152             <li> nested stuff </li>
153           </ul>
154         </li>
155       </ul>
156     </td>
157   </tr>
158   <tr bgcolor="#ffffff">
159     <td valign="top"><strong>Ordered List:</strong><br /> Three spaces and a number. </td>
160     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
161         1 Sushi
162         1 Dim Sum
163 </pre> </font></span></td>
164     <td valign="top">
165       <ol>
166         <li> Sushi </li>
167         <li> Dim Sum </li>
168       </ol>
169     </td>
170   </tr>
171   <tr bgcolor="#ffffff">
172     <td valign="top"><strong>Definition List:</strong><br /> Three spaces, the term, a colon, a space, followed by the definition. <br /><strong><em>Note:</em></strong> Terms with spaces are not supported. In case you do have a term with more then one word, separate the words with dashes or with the <code>&amp;nbsp;</code> non-breaking-space entity. </td>
173     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
174         Sushi: Japan
175         Dim&amp;nbsp;Sum: S.F.
176 </pre> </font></span></td>
177     <td valign="top">
178       <dl>
179         <dt> Sushi</dt>
180         <dd> Japan </dd>
181         <dt> Dim Sum</dt>
182         <dd> S.F. </dd>
183       </dl>
184     </td>
185   </tr>
186   <tr bgcolor="#ffffff">
187     <td valign="top"><strong>Table:</strong><br /> Optional spaces followed by the cells enclosed in vertical bars. <br /><strong><em>Note:</em></strong> <code>| *bold* |</code> cells are rendered as table headers. <br /><strong><em>Note:</em></strong> <code>|   spaced   |</code> cells are rendered center aligned. <br /><strong><em>Note:</em></strong> <code>|     spaced |</code> cells are rendered right aligned. <br /><strong><em>Note:</em></strong> <code>| 2 colspan ||</code> cells are rendered as multi-span columns. <br /><strong><em>Note:</em></strong> In case you have a long row and you want it to be more readable when you edit the table you can split the row into lines that end with a <code>'\'</code> backslash character. <br />
188     </td>
189     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
190 | *L* | *C* | *R* |
191 | A2 |  2  |  2 |
192 | A3 |  3  |  3 |
193 | multi span |||
194 | A4 \  | next \  | next |
195 </pre> </font></span></td>
196     <td valign="top">
197       <table border="1" cellpadding="0" cellspacing="0">
198         <tr>
199           <th bgcolor="#99CCCC"><strong> L </strong></th>
200           <th bgcolor="#99CCCC"><strong> C </strong></th>
201           <th bgcolor="#99CCCC"><strong> R </strong></th>
202         </tr>
203         <tr>
204           <td> A2 </td>
205           <td align="center"> 2 </td>
206           <td align="right"> 2 </td>
207         </tr>
208         <tr>
209           <td> A3 </td>
210           <td align="center"> 3 </td>
211           <td align="right"> 3 </td>
212         </tr>
213         <tr>
214           <td colspan="3"> multi span </td>
215         </tr>
216         <tr>
217           <td> A4 </td>
218           <td> next </td>
219           <td> next </td>
220         </tr>
221       </table>
222     </td>
223   </tr>
224   <tr bgcolor="#ffffff">
225     <td valign="top"><strong>WikiWord Links:</strong><br /> CapitalizedWordsStuckTogether (or [[Main/WikiWords]]) will produce a link automatically. <br /><strong><em>Note:</em></strong> In case you want to link to a topic in a different %WIKITOOLNAME% web write <code>Webname.TopicName</code>. </td>
226     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
227 WebNotify
228
229 Know.ReadmeFirst
230 </pre> </font></span></td>
231     <td valign="top">[[Main/WebNotify]]<p>[[Know/ReadmeFirst]]</p>
232     </td>
233   </tr>
234   <tr bgcolor="#ffffff">
235     <td valign="top"><a name="SquareBrackets"></a> <strong>Forced Links:</strong><br /> You can create a forced internal link by enclosing words in double square brackets. <br /><strong><em>Note:</em></strong> Text within the brackets may contain optional spaces; the topic name is formed by capitalizing the initial letter and by removing the spaces; i.e. <code>[[text formatting FAQ]]</code> links to topic [[Main/TextFormattingFAQ]]. You can also refer to a different web and use anchors. </td>
236     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
237 [[wiki syntax]]
238
239 [[Main.TWiki users]]
240 </pre> </font></span></td>
241     <td valign="top">[[Main/WikiSyntax]]<p>[[Main/TWikiUsers]]</p>
242     </td>
243   </tr>
244   <tr bgcolor="#ffffff">
245     <td valign="top"><strong>Specific Links:</strong><br /> Create a link where you can specify the link text and the link reference separately, using nested square brackets like <code>[[reference][text]]</code>. Internal link references (i.e. [[Main/WikiSyntax]]) and external link references (i.e. <a href="http://TWiki.org/" target="_top">http://TWiki.org/</a>) are supported. The same <strong><em>Forced Links</em></strong> rules apply for internal link references. Anchor names can be added as well, like <code>[[WebHome#MyAnchor][go home]]</code> and <code>[[http://www.yahoo.com/#somewhere][Yahoo!]]</code>. </td>
246     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
247 [[WikiSyntax][syntax]]
248
249 [[http://gnu.org][GNU]]
250 </pre> </font></span></td>
251     <td valign="top">[[Main/WikiSyntax]]<p><a href="http://gnu.org" target="_top">GNU</a></p>
252     </td>
253   </tr>
254   <tr bgcolor="#ffffff">
255     <td valign="top"><strong>Easier External Links:</strong><br /> An easier syntax for external links is now available: <code>[[externalURL text]]</code> - just hit the spacebar to separate the link URL from the descriptive text, e.g. <code>[[http://gnu.org/ GNU]]</code>. This also supports anchors, e.g. <code>[[http://www.yahoo.com/#somewhere Yahoo!]]</code>. </td>
256     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
257 [[http://gnu.org GNU]]
258 </pre> </font></span></td>
259     <td valign="top"><a href="http://gnu.org" target="_top">GNU</a></td>
260   </tr>
261   <tr bgcolor="#ffffff">
262     <td valign="top"><strong>Anchors:</strong><br /> You can define a link reference inside a %WIKITOOLNAME% topic (called an anchor name) and link to that. To <strong><em>define</em></strong> an anchor write <code>#AnchorName</code> at the beginning of a line. The anchor name must be a [[Main/WikiWord]]. To <strong><em>link to</em></strong> an anchor name use the <code>[[MyTopic#MyAnchor]]</code> syntax. You can omit the topic name if you want to link within the same topic. </td>
263     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
264 [[WebHome#NotThere]]
265
266 [[#MyAnchor][Jump]]
267
268 #MyAnchor To here
269 </pre> </font></span></td>
270     <td valign="top">[[Main/WebHome#NotThere]]<p>[[Main/WebHome#MyAnchor]]</p>
271       <p><a name="MyAnchor"></a> To here </p>
272     </td>
273   </tr>
274   <tr bgcolor="#ffffff">
275     <td valign="top"><strong>Prevent a Link:</strong> %BR% Prevent a [[Main/WikiWord]] from being linked by prepending it with the <code>&lt;nop&gt;</code> tag. </td>
276     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
277 &lt;nop&gt;SunOS
278 </pre> </font></span></td>
279     <td valign="top"> SunOS </td>
280   </tr>
281   <tr bgcolor="#ffffff">
282     <td valign="top"><strong>Disable Links:</strong> %BR% You can disable automatic linking of [[Main/WikiWords]] by surrounding text with <code>&lt;noautolink&gt;</code> and <code>&lt;/noautolink&gt;</code> tags. %BR% <strong><em>Note:</em></strong> Each tag must be on a line by itself.%BR% <strong><em>Note:</em></strong> This also works for TWiki tables, but only if you add a blank line between the end of the table and the closing <code>&lt;/noautolink&gt;</code> tag (known issue of the [[Main/TablePlugin]]). </td>
283     <td valign="top"><span style="background: #FFFFCC"><font color="#990000"> <pre>
284  &lt;noautolink&gt;
285  RedHat &amp;
286  SuSE
287  &lt;/noautolink&gt;
288 </pre> </font></span></td>
289     <td valign="top"> RedHat &amp; SuSE </td>
290   </tr>
291 </table>
292
293 ## <a name="Using HTML"></a> Using HTML
294
295 You can use just about any HTML tag without a problem - however, there are a few usability and technical considerations to keep in mind.
296
297 ### <a name="HTML and TWiki Usability"></a> HTML and TWiki Usability
298
299 - On collaboration pages, it's preferable NOT to use HTML, and to use [[TWiki shorthand|Main/WebHome#TWikiShorthand]] instead - this keeps the text uncluttered and easy to edit.
300 - %X% **NOTE:** TWiki is designed to work with a wide range of browsers and computer platforms, holding to HTML 3.2 compatibility in the standard installation - adding raw HTML, particularly browser-specific tags (or any other mark-up that doesn't degrade well) will reduce compatibility.
301
302 ### <a name="TWiki HTML Rendering"></a> TWiki HTML Rendering
303
304 - TWiki converts shorthand notation to XHTML 1.0 for display. To copy a fully marked-up page, simply view source in your browser and save the contents.
305   - %T% If you need to save HTML frequently, you may want to check out TWiki:Plugins/GenHTMLAddon - it will "generate a directory containing rendered versions of a set of TWiki pages together with any attached files."
306 - %X% **NOTE:** The opening and closing angle brackets - <code>**&lt;...&gt;**</code> - of an HTML tag **_must be on the same line_**, or the tag will be broken.
307   - This feature allows you to enter an unclosed angle bracket - as a greater than or less than symbol - and have it automatically rendered as if you had entered its HTML character, `&lt;`, ex: <code>**a &gt; b**</code>
308   - %T% If you're pasting in preformatted HTML text and notice problems, check the file in a text processor with no text wrap. Also, save without hard line breaks on text wrap, in your HTML editing program.
309
310 ## <a name="Hyperlinks"></a> Hyperlinks
311
312 Being able to create links without any formatting required is a core TWiki feature, made possible with [[WikiWords]]. New TWiki linking rules are a simple extension of the syntax that provide a new set of flexible options.
313
314 ### <a name="Internal Links"></a> Internal Links
315
316 - [[GoodStyle]] is a [[WikiWord]] that links to the GoodStyle topic located in the current %WIKITOOLNAME% web.
317
318 - [[NotExistingYet]] is a topic waiting to be written. Create the topic by clicking on the **?**. (Try clicking, but then, **Cancel** - creating the topic would wreck this example!)
319
320 ### <a name="External Links"></a> External Links
321
322 - `http://...`, `https://...`, `ftp://...` and `mailto:...@...` are linked automatically.
323
324 - Email addresses like `name@domain.com` are linked automatically.
325
326 - `[[Square bracket rules]]` let you easily create [[non-WikiWord links|Main/WebHome#SquareBrackets]].
327   - You can also write `[[http://yahoo.com Yahoo home page]]` as an easier way of doing external links with descriptive text for the link, such as [Yahoo home page](http://yahoo.com).
328
329 ## <a name="TWiki Variables"></a> TWiki Variables
330
331 Variables are names that are enclosed in percent signs `%` that are expanded on the fly.
332
333 - `%TOC%` : Automatically generates a table of contents based on headings in a topic - see the top of this page for an example.
334
335 - `%WEB%` : The current web, is **%WEB%**.
336
337 - `%TOPIC%` : The current topic name, is **%TOPIC%**.
338
339 - `%ATTACHURL%` : The attachment URL of the current topic. Example usage: If you attach a file to a topic you can refer to it as <code>**%ATTACHURL%/image.gif**</code> to show the URL of the file or the image in your text.
340
341 - `%INCLUDE{"SomeTopic"}%` : Server side include, includes another topic. The current %WIKITOOLNAME% web is the default web. Example: <code>**%INCLUDE\{"TWiki.SiteMap"\}%**</code>
342
343 - There are many more variables, see **[[TWikiVariables]]**.
344
345 - [[TWikiPreferences]] defines site-wide variables like colors. For example, write: <code><span><font> %RED% Red %ENDCOLOR% and %BLUE% blue %ENDCOLOR% colors</font></span></code> to get: %RED% Red %ENDCOLOR% and %BLUE% blue %ENDCOLOR% colors.
346
347 ## <a name="TWikiPlugin Formatting Extension"></a><a name="_TWikiPlugin Formatting Extensio"></a> TWikiPlugin Formatting Extensions
348
349 Plugins provide additional text formatting capabilities and can extend the functionality of %WIKITOOLNAME% into many other areas. For example, the optional [SpreadSheetPlugin](http://twiki.org/cgi-bin/view/Plugins/SpreadSheetPlugin) lets you create a spreadsheet with the same basic notation used in TWiki tables.
350
351 Available Plugins are located in the [Plugins](http://twiki.org/cgi-bin/view/Plugins) web on TWiki.org. Currently enabled plugins on this TWiki installation, as listed by `%PLUGINDESCRIPTIONS%`:
352
353 - [[SpreadSheetPlugin]] <span>(any TWiki, 10197)</span>:
354 - [[CommentPlugin]] <span>(Dakar, 11359)</span>: Allows users to quickly post comments to a page without an edit/preview/save cycle
355 - [[EditTablePlugin]] <span>(any TWiki, 11646)</span>:
356 - [[InterwikiPlugin]] <span>(Dakar, $Rev: 11935$)</span>:
357 - [[PreferencesPlugin]] <span>(Dakar, 9839)</span>:
358 - [[SlideShowPlugin]] <span>(Any TWiki, $Rev: 12847$)</span>:
359 - [[SmiliesPlugin]] <span>(Dakar, 8154)</span>:
360 - [[TablePlugin]] <span>(1.020, 12339)</span>:
361 - [[TwistyPlugin]] <span>(1.2.0, $Rev: 12154$)</span>:
362
363 Check on current Plugin status and settings for this site in [[TWikiPreferences]].
364
365 ## <a name="Common Editing Errors"></a> Common Editing Errors
366
367 TWiki formatting rules are fairly simple to use and quick to type. However, there are some things to watch out for, taken from the [[TextFormattingFAQ]]:
368
369 - **Q:** Text enclosed in angle brackets like `<filename>` is not displayed. How can I show it as it is?
370   - **A:** The `'<'` and `'>'` characters have a special meaning in HTML, they define HTML tags. You need to escape them, so write `'&lt;'` instead of `'<'`, and `'&gt;'` instead of `'>'`. <br /> Example: Type `'prog &lt;filename&gt;'` to get `'prog <filename>'`.
371
372 - **Q:** Why is the `'&'` character sometimes not displayed?
373   - **A:** The `'&'` character has a special meaning in HTML, it starts a so called character entity, i.e. `'&copy;'` is the `©` copyright character. You need to escape `'&'` to see it as it is, so write `'&amp;'` instead of `'&'`. <br /> Example: Type `'This &amp; that'` to get `'This & that'`.
374
375 -- [[MikeMannix]] - 02 Dec 2001 <br /> -- [[PeterThoeny]] - 02 May 2002