What is Topic Markup Language (TML)?

The special text format used in Foswiki topics to simplify topic text.

Foswiki lets you work using a WYSIWYG editor, which for most people is the easiest way to enter and edit text. many people prefer typing and editing in plain text (i.e. text without visible formatting), and Foswiki provides a simple formatting language called TML (Topic Markup Language) for this (you don't need to know HTML, though you can use it if you want). Topics are stored in TML, and differences are displayed using it, so it's worth knowing the basics even if you only use WYSIWYG. It's all laid out below.

Markup Basics

A quick introduction:

  • Separate each paragraph with a blank line.

  • To display a bold type word or phrase, use asterisks: *bold type*.

  • To display an italic word or phrase, use underscores: _italic_.

  • To display bold with italics word or phrase, use double underscores: __bold italic__.

  • To display a word or phrase in MONOSPACED TYPE, use equal signs: =like this=.

  • Use ==double equal signs== for bold: bold mono.

  • To display colored text, enter:__ %RED% red text %ENDCOLOR% and %GREEN% green text %ENDCOLOR% to get red text and green text .
    • %<color>% text must end with %ENDCOLOR%. If you want to switch from one color to another one you first need to end the active color with %ENDCOLOR%, e.g. write %RED% some text %ENDCOLOR% %GREEN% more text %ENDCOLOR%.
    • Default Preferences defines some commonly used colors: %YELLOW%, %RED%, %PINK%, %PURPLE%, %TEAL%, %NAVY%, %BLUE%, %AQUA%, %LIME%, %GREEN%, %OLIVE%, %MAROON%, %BLACK%, %GRAY%, %SILVER% and %ENDCOLOR%.

  • To display headings, type (from the beginning of a line) three dashes (-), from one to six plus signs (+), a space, and your heading text.
    • The quantity of plus signs is related to the size of the heading - the more plus signs you use, the smaller the heading.
    • You can insert a nested table of contents, generated from headings, by placing %TOC% wherever you like on a page (see System.Macros for more %TOC% options).

  • Use <verbatim> to enclose code excerpts, filenames, and other unformatted text:
     <verbatim>
     unformatted text!
     and more of it!
     </verbatim>

Formatting text

Full list of text formatting capabilities:

Formatting Command: You write: You get:
Paragraphs:
Blank lines will create new paragraphs.
1st paragraph

2nd paragraph

1st paragraph

2nd paragraph
Headings:
Three or more dashes at the beginning of a line, followed by plus signs and the heading text. One plus creates a top level heading, two pluses a second level heading, etc. The maximum heading depth is 6.

You can create a table of contents with the %TOC% macro. If you want to exclude a heading from the TOC, put !! after the ---+.

ALERT! Empty headings are allowed, but won't appear in the table of contents.

See the <ho> tag below for how to adjust heading levels dynamically.

---++ Sushi
---+++ Maguro
---+++!! Not in TOC

Sushi

Maguro

Not in TOC

Bold Text:
Words get shown in bold by enclosing them in * asterisks.
*Bold*

Bold
Italic Text:
Words get shown in italic by enclosing them in _ underscores.
_Italic_

Italic
Bold Italic:
Words get shown in bold italic by enclosing them in __ double-underscores.
__Bold italic__

Bold italic
Fixed Font:
Words get shown in fixed font by enclosing them in = equal signs.
=Fixed font=

Fixed font

Bold Fixed Font:
Words get shown in bold fixed font by enclosing them in == double equal signs.
==Bold fixed==

Bold fixed
TIP You can follow the closing bold, italic, or other (* _ __ = ==) indicator with normal punctuation, such as commas and full stops.

ALERT! Make sure there is no space between the text and the indicators.
_This works_,
_this does not _

This works,
_this does not _
Separator (Horizontal Rule):
Three or more three dashes at the beginning of a line..
---


Bulleted List:
Multiple of three spaces, an asterisk, and another space.

HELP For all the list types, you can break a list item over several lines by indenting lines after the first one by at least 3 spaces.
   * level 1
      * level 2
   * back on 1
   * A bullet
     broken over
     three lines
   * last bullet

  • level 1
    • level 2
  • back on 1
  • A bullet broken over three lines
  • last bullet
Numbered List:
Multiple of three spaces, a type character, a dot, and another space. Several types are available besides a number:
Type Generated Style Sample Sequence
1. Arabic numerals 1, 2, 3, 4...
A. Uppercase letters A, B, C, D...
a. Lowercase letters a, b, c, d...
I. Uppercase Roman Numerals I, II, III, IV...
i. Lowercase Roman Numerals i, ii, iii, iv...
ALERT! Note that while type characters A, a, I and i must be entered exactly as specified, numbers can be any single digit 0-9. It is recommended for future compatibility that only the number 1 be used for numbered type lists.
   1. Sushi
   1. Dim Sum
   1. Fondue

   A. Sushi
   A. Dim Sum
   A. Fondue

   i. Sushi
   i. Dim Sum
   i. Fondue

  1. Sushi
  2. Dim Sum
  3. Fondue

  1. Sushi
  2. Dim Sum
  3. Fondue

  1. Sushi
  2. Dim Sum
  3. Fondue
Definition List:
Three spaces, a dollar sign, the term, a colon, a space, followed by the definition.
   $ Sushi: Japan
   $ Dim Sum: S.F.

Sushi
Japan
Dim Sum
S.F.
Definition List: (deprecated)
Three spaces, the term (a single word, no spaces), a colon, a space, followed by the definition.
   Sushi: Japan
   Dim-Sum: S.F.

Sushi
Japan
Dim-Sum
S.F.
Indented Text:
Three spaces, a colon, a space, followed by the paragraph.
  • Continue a paragraph by indenting the line with 3 spaces.
  • Create deeper levels of indentation by using multiples of 3 spaces.
   : Indented line
   Continued
   : New paragraph
      : 2nd level indent

Indented line Continued
New paragraph
2nd level indent
Table:
Each row of the table is a line containing of one or more cells. Each cell starts and ends with a vertical bar '|'. Any spaces at the beginning of a line are ignored.
| *bold* | header cell with text in asterisks
|   center-aligned   | cell with at least two, and equal number of spaces on either side
|      right-aligned | cell with more spaces on the left
| 2 colspan || and multi-span columns with multiple |'s right next to each other
|^| cell with caret indicating follow-up row of multi-span rows
  • You can split rows over multiple lines by putting a backslash '\' at the end of each line
  • Contents of table cells wrap automatically as determined by the browser
  • Use %VBAR% or &#124; to add | characters in tables.
  • Use %CARET% or &#94; to add ^ characters in tables.
TIP The Table Plugin provides the |^| multiple-span row functionality and additional rendering features
| *L* | *C* | *R* |
| A2 |  B2  |  C2 |
  | A3 |  B3  |  C3 |
| multi span |||
| A5-7 |  5  |  5 |
|^| six | six |
|^| seven | seven |
| split\
  | over\
  | 3 lines |
| A9 |  B9  |  C9 |
| %CARET% | B10 |%VBAR%|
| &#94; | B11 |&#124;|

L C R
A2 B2 C2
A3 B3 C3
multi span
A5-7 5 5
six six
seven seven
split over 3 lines
A9 B9 C9
^ B10 |
^ B11 |
WikiWord Links:
CapitalizedWordsStuckTogether (or Wiki Words) will produce a link automatically if preceded by whitespace or parenthesis.
  • TIP If you want to link to a topic in a different web write Otherweb.TopicName.
  • To link to a topic in a subweb write Otherweb.Subweb.TopicName.
  • HELP The link label excludes the name of the web, e.g. only the topic name is shown. As an exception, the name of the web is shown for the WebHome topic.
ALERT! Dots '.' are used to separate webs and subwebs from topic names and therefore cannot be used in topic names.

It's generally a good idea to use the macros %SYSTEMWEB%, %SANDBOXWEB% and %USERSWEB% instead of System, Sandbox and Users.

To prevent a word from linking, prefix it with the exclaimation mark (!) or <nop>
%STATISTICSTOPIC%

%SANDBOXWEB%.WebNotify

%SANDBOXWEB%.%HOMETOPIC%

%SANDBOXWEB%.Subweb.TopicName

Web Statistics

Web Notify

Sandbox

TopicName
Acronym Links:
Words that are all capitals will produce a link automatically only if the topic already exists!.
ACRONYM

%SYSTEMWEB%.ACRONYM

ACRONYM

ACRONYM
Anchors:
You can define a reference inside a topic (called an anchor name) and link to that. To define an anchor write #AnchorName at the beginning of a line. The anchor name must be a Wiki Word of no more than 32 characters. To link to an anchor name use the [[MyTopic#MyAnchor]] syntax. You can omit the topic name if you want to link within the same topic.
[[WikiWord#NotThere]]

[[#MyAnchor][Jump]]

#MyAnchor To here

Wiki Word#Not There

Jump

To here
Forced Links:
You can create a forced internal link by enclosing words in double square brackets.
Text within the brackets may contain optional spaces; the topic name is formed by capitalizing the initial letter and by removing the spaces; for example, [[wiki word]] links to topic Wiki Word. You can also refer to a different web and use anchors.
TIP To "escape" double square brackets that would otherwise make a link, prefix the leading left square bracket with an exclamation point.
[[wiki syntax]]

[[Users.Wiki groups]]

escaped:
![[wiki syntax]]

wiki syntax

Users.Wiki groups

escaped: [[wiki syntax]]
Renamed Links:
You can create a link where you specify the link text and the URL separately using nested square brackets [[reference][text]]. Internal link references (e.g. Wiki Word) and URLs (e.g. https://foswiki.org/) are both supported. The rules described under Forced Links apply for internal link references.
TIP Anchor names can be added as well, to create a link to a specific place in a topic.
[[WikiWord][wiki word]]

[[http://gnu.org][GNU]]

wiki word

GNU
Automatic links:
Typed-in URLs are linked automatically. Most standard protocols are supported; if yours is missing, it can be added by the site administrator.

URLs for images are automatically inserted inline.

Email addresses are also linked automatically, see further details below.

TIP automatic linking of URLs and email addresses is not blocked by the noautolink setting.
   * file://foswiki.org
   * ftp://foswiki.org
   * http://foswiki.org
   * https://foswiki.org
   * mailto:example@foswiki.org
   * news://foswiki.org
   * nntp://foswiki.org
   * telnet://foswiki.org
   * name@foswiki.org
   * %PUBURL%/%SYSTEMWEB%/ProjectLogos/foswiki-logo-icon.png
Prevent an Automatic Link:
Prevent a Wiki Word, URL, email address or image from being linked by prepending it with an exclamation point (!) or <nop> tag.

TIP Note that you can use the <nop> tag, but any leading markup directly adjacent to a wikiword will prevent automatic linking because the word is no longer space delimitied.
!SunOS

<nop>SomeWiki

<b>SomeWiki</b>

=SomeWiki=

<b>https://foswiki.org</b>

_%PUBURL%/%SYSTEMWEB%/ProjectLogos/foswiki-logo-icon.png_

SunOS

SomeWiki

SomeWiki

SomeWiki

https://foswiki.org

https://the-data-mine.com/pub/System/ProjectLogos/foswiki-logo-icon.png
Disable Automatic Linking:
You can disable automatic linking of Wiki Words by surrounding text with <noautolink> and </noautolink> tags.
HELP You can also turn off Wiki Word auto-linking with the NOAUTOLINK preference setting.

The noautolink feature only applies to WikiWords. It does not stop linking of URLs, or email addresses.
 <noautolink>
 RedHat & SuSE
 </noautolink>

RedHat & SuSE
Mailto Links:
E-mail addresses are linked automatically. To create e-mail links that have more descriptive link text, specify subject lines or message bodies, or omit the e-mail address, you can write [[mailto:user@domain][descriptive text]].

ALERT! automatic linking of email addresses is not blocked by <noautolink>, Escape with a ! to prevent auto linking.
a@b.com

[[mailto:a@b.com][Mail]]

[[mailto:?subject=Hi][Hi]]

!a@b.com

a@b.com

Mail

Hi

a@b.com
Special characters:
Some characters are reserved for use by TML
  • Display them in your output by using the HTML entities.
  • Use HTML entities to display characters that are not supported by your site character set (e.g. special mathematical symbols). There's a complete list of named entities in Wikipedia
  • Use numerical entities to display any unicode character (e.g. Chinese script).
&lt; &gt; &amp; &alefsym; &#x4eb9;

A <nop>!= B &#33;= C

<nop>!here, !here
< > & ℵ 亹

A != B != C

!here, here
Escapes
Escapes are used to prevent a "default action" from occuring. They are used in many places when composing topics and writing Foswiki macros.
!
The exclamation point will block expansion of macros, prevents automatic linking of Wiki Words, email addresses, URLs, and [[explicit links]].
  • To expand a macro, but escape any wikiword it expands into, use the <nop> tag.
  • To prevent Foswiki from treating ! as an escape, escape it with <nop>, or use the &#33; entity
\
The backslash is used to prevent normal interpretation of a character, allowing inclusion of quotes inside a quoted string. It can also be used to continue a line (escapes the "newline"). When used as a "continue" it must be the very last character prior to the newline.
<nop>
The nop (no operation) is used to prevent linking of WikiWords, email addresses, URLs, but not Macros or [[explicit links]]
!WikiWord %BR%
&#37;TOPIC% %BR%
<nop>%TOPIC% %BR%
<nop>%WIKIWEBMASTER% %BR%
<nop>!%TOPIC% %BR%
!here &#33;here <nop>!here %BR%
%TOP\
IC%


WikiWord
%TOPIC%
EditingShorthand
andy@the-data-mine.com
!EditingShorthand
here !here !here
%TOPIC%
Controlling how content is rendered:
There are 3 ways to control how your topic content is rendered. This is done with three HTML or pseudo-HTML tags: <literal>, <verbatim> and <pre> They control whether or not:
  • Wiki markup (TML) is rendered
  • Macros (ex: %TOPIC%) are expanded
  • HTML is rendered
  • White space preserved
  • Auto linking of WikiWords and Email addresses occurs
These are explained in more details in the next sections, but are summarized to the right:
TMLHTMLMacrosWhite
Space
Auto Link
WikiWord
Auto Link
Email
<verbatim> ALERT!ALERT!ALERT!DONEALERT!ALERT!
<literal> ALERT!DONEDONEALERT!ALERT!ALERT!
<pre> ALERT!DONEDONEDONEALERT!ALERT!
<noautolink> DONEDONEDONEALERT!ALERT!DONE
Literal content:
Foswiki generates HTML code from TML shorthand. Experts surround anything that must be output literally in the HTML code, without the application of shorthand rules, with <literal>..</literal> tags.
ALERT! Any HTML within literal tags must be well formed i.e. all tags must be properly closed before the end of the literal block.
IDEA! Macros are expanded within literal blocks.
<literal>
| Not | A | Table |
</literal>
| Not | A | Table |
Verbatim (Literal) Text:
Surround code excerpts and other formatted text with <verbatim> and </verbatim> tags.

TIP verbatim tags disable HTML code. Use <pre> and </pre> tags instead if you want the HTML code within the tags to be interpreted.

ALERT! Preferences settings (* Set NAME = value) are set within verbatim tags.
<verbatim>
class CatAnimal {
  void purr() {
    <code here>
  }
}
</verbatim>
class CatAnimal {
  void purr() {
    <code here>
  }
}
Verbatim (Literal) Code Highlighting:
Surround code excerpts and other formatted text e.g. with <verbatim class="bash"> and </verbatim> tags.

IDEA! This type of code highlighting is based on Chili - the jQuery code highlighter plugin. Please find supported class attributes in J Query Chili.

TIP verbatim tags disable HTML code. Use <pre class="bash"> and </pre> tags instead if you want the HTML code within the tags to be interpreted.

ALERT! Preferences settings (* Set NAME = value) are set within verbatim tags.
<verbatim class="bash">
#!/bin/bash
while [ -n "$(ls . ~/ \
~/pub* /var/www 2>/dev/null \
| fgrep foswiki )" ] ; do
 clear
 printf "\nFoswiki rules!\n"
 sleep 10
 clear
 printf "\nFoswiki still rules!\n"
 sleep 10
done; exit 0
</verbatim>
#!/bin/bash
while [ -n "$(ls . ~/ \
~/pub* /var/www 2>/dev/null \
| fgrep foswiki )" ] ; do
 clear
 printf "\nFoswiki rules!\n"
 sleep 10
 clear
 printf "\nFoswiki still rules!\n"
 sleep 10
done; exit 0

Protected content:
Experts protect text from mangling by WYSIWYG editors using <sticky>..</sticky> tags. Sticky tags don't have any effect on normal topic display; they are only relevant when content has to be protected from a WYSIWYG editor (usually because it isn't well-formed HTML, or because it is HTML that WYSIWYG would normally filter out or modify). Protected content appears as plain text in the WYSIWYG editor.
ALERT! Any HTML within sticky tags must be well formed i.e. all tags must be properly closed before the end of the sticky block.
IDEA! Macros are expanded within sticky blocks.
<sticky>
<div>
This div 
%RED%is%ENDCOLOR%
required
</div>
</sticky>

This div is required

Adjust heading levels:
You can adjust heading levels for headings generated using ---+ markup and also HTML <h> tags using the <ho> tag.
The %INCLUDE and %SEARCH macros also have a headingoffset parameter to do this for you in included content.
Heading levels are limited to the range 1..6 after any offset is applied.
---++ offset is 0
<ho off="1">
---++ H2 becomes H3
<ho off="-1">
---++ offset was 1, so offset is now 0

offset is 0

H2 becomes H3

offset was 1, so offset is now 0

Using HTML

You can use most HTML tags in topics without a problem. This is useful where you want to add some content that is formatted in a way that is not supported using wiki syntax, for example, you can write <strike>deleted text</strike> to get deleted text.

There are a few usability and technical considerations to keep in mind:
  • On collaboration pages, it's better not to use HTML, but to use wiki syntax instead - this keeps the text uncluttered and easy to edit using the plaintext editor.
  • If you must use HTML, use XHTML 1.0 Transitional syntax.
  • Use <literal>..</literal> tags around blocks of HTML to avoid accidental interpretation of Wiki syntax within the HTML.
ALERT! Script tags may be filtered out, at the discretion of your Wiki administrator.

Recommendations when pasting HTML from other sources (using the plain-text editor):
  • Copy only text between <body> and </body> tags.
  • Remove all empty lines. Foswiki inserts <p /> paragraph tags on empty lines, which causes problems if done between HTML tags that do not allow paragraph tags, like for example between table tags.
  • Remove leading spaces. Foswiki might interpret some text as lists.
  • Do not span a tag over more than one line. Foswiki requires that the opening and closing angle brackets - <...> - of a HTML tag are on the same line, or the tag will be broken.
  • In your HTML editing program, save without hard line breaks on text wrap.

When using a WYSIWYG editor, you can just copy-paste directly into the editor, and the content will be converted to wiki syntax automatically when you save.

Macros

Macros are names enclosed in percent signs that are that are expanded to some other text when the topic is displayed. For example, %TOPIC% is expanded to Topic Markup Language, the title of this topic.

Some macros can take arguments in curly braces - for example, %INCLUDE{"OtherTopic" ARG="arg"}%.

Macros are fully expanded before any of the text formatting rules are applied.

Many macro definitions are built-in, and others (preference settings) are predefined for your convenience. You can also define your own preference settings at the entire site, individual web, or individual topic level. For more information, see Macros Plugins can extend the functionality of Foswiki into many other areas, and often implement new macros. There are a huge number of plugins available from the foswiki site. Check on current Plugin status and settings for this site in System.Installed Plugins.

Common Editing Errors

Foswiki formatting rules are fairly simple to use and quick to type. However, there are some things to watch out for:

  • Q: Text enclosed in angle brackets like <filename> is not displayed. How can I show it as it is?
    • 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 '>'.
      Example: Type 'prog &lt;filename&gt;' to get 'prog <filename>'.

  • Q: Why is the '&' character sometimes not displayed?
    • 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 '&'.
      Example: Type 'This &amp; that' to get 'This & that'.


Related Topics: WYSIWYG
Topic revision: r1 - 13 Apr 2016, ProjectContributor
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback