Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Advanced use of Markdown.

Advanced use of Markdown

From MoodleDocs

Line Breaks

In some texts, for instance in poetry and verse, it is often necessary to insert line breaks. Trying to do so with the return key will not give the intended effect as by default the lines will be run together to create a paragraph.

The best laid schemes o' Mice an' Men,
Gang aft agley,
An' lea'e us nought but grief an' pain,
For promis'd joy!

The above input, using the enter key to insert line breaks will give the following output as such breaks are ignored:

The best laid schemes o' Mice an' Men, Gang aft agley, An' lea'e us nought but grief an' pain, For promis'd joy!

But by ending each line with two spaces you can force a line break as follows:

The best laid schemes o' Mice an' Men,
Gang aft agley,
An' lea'e us nought but grief an' pain,
For promis'd joy!

Horizontal Rules

Horizontal rules can be created by placing three or more asterisks (*), hyphens (-) or underscores (_) on a line by themselves.

This will work:

***

but you can add spaces or further characters to make it more obviously a section break in the text editing window e.g.

* * * * *
-------------------------
_ _ _ _ _

All of these methods give a horizontal rule.

Tables

You can create simple HTML tables with Markdown. Here is an example:

Name    |   Age
--------|------
Fred    |   29
Jim     |   47
Harry   |   32
Name Age
Fred 29
Jim 47
Harry 32


You can apply normal formatting to the cell contents. Columns can be left or right aligned by adding a colon the left or the right of the horizontal bar (see additional instructions).

Definition Lists

Definition lists consist of terms followed by their definitions. Rather like a dictionary. A simple example is as follows:

Moodle
:   A well-known online learning platform
PHP
:   A scripting language.
   Mostly used for developing interactive web applications.
Moodle
A well-known online learning platform
PHP
A scripting language. Mostly used for developing interactive web applications.

Footnotes

A footnote has two elements. A marker in the text which will become a superscript number and a footnote definition that will appear at the end of the document. Here is a simple example:

Read about it in my book.[^1]
[^1]: All about my book.

You can place the footnote definitions anywhere you like. They will be listed in the order that they are linked to in the text. You cannot make more than one link to the same footnote.

Embedding HTML

If you are already proficient in HTML then there may be occasions when Markdown does not allow you as much control as you are used to. Luckily Markdown is designed for this eventuality and allows you to embed HTML directly within Markdown formatted text.

Note that the HTML markup co-exists with the Markdown code for bullet lists. This frees you from the mundane task of writing complex HTML for basic formatting features such as paragraphs and lists while still allowing you to access the full power of HTML in specific situations.

Displaying HTML or Preformatted Text

If you wish the HTML you enter to be displayed exactly as you typed it, rather than processed as HTML then you can start each line with four space characters.

<p>A paragraph in <b>HTML</b> displayed as code</p>

This also works for displaying computer code:

print "Command-line arguments: (@ARGV)\n";

As this formatting is often used for computer program listings and other text which may plausibly contain the characters that Markdown uses to indicate different types of formatting, Markdown's formatting is switched off for these lines:

Normally this word would be **bold**.

To include such characters within normal text, see the section below.

Using Special Characters

If you wish to use any of the special characters that trigger Markdown formatting without them being processed simply precede them with a backslash character (\). This is known as 'escaping' a character. The backslash is not displayed but the character immediately following it is shown, exactly as entered.

\*asterisks, not emphasis\*

becomes

*asterisks, not emphasis*

rather than

*emphasis, not asterisks*

which gives

emphasis, not asterisks

See also

The Markdown system is not unique to Moodle, it is used in an ever increasing number of web publishing tools. You can find out more about it at http://daringfireball.net/projects/markdown/

Moodle uses a version of Markdown with additional features known as "Markdown Extra". Further information can be found at http://www.michelf.com/projects/php-markdown/extra/ .