Monday, June 22, 2009

Markdown

Markdown is a simple syntax for writing text documents. It is better than HTML since it does not contain as much clutter. HTML may be used in a Markdown document but block level elements must be surrounded with blank lines.

Headers

Headers come in two types.

  • Underlined headers, =====, and -----
  • Prefix headers, which uses # as prefix, # = h1, and ### = h3

Emphasis

  • Emphasis can be shown with * or with _ .
  • If you double them up they will become strong instead ** and __

List

  • Unordered lists are indicated with *, + or -
  • Ordered lists are indicated with number followed by period, 1.

Lists may be span several lines and may also use hanging indents. To wrap the list items in paragraphs simply leave a blank line between item lines.

Blockquotes

Blockquotes are indicated by prefixing lines with >. They may be nested > > . If you only prefix the first line in a paragraph, everything up to the next blank line will be part of the blockquote.

Code

Markdown produces literal markup if the lines are indented with one tab or four spaces. This kind of code will be wrapped with <pre><code>

Lines

Lines may be indicated by putting three or more asterisks (***) or hyphens (---) on a line by itself.

Links

Markdown support both inline and reference links.

Inline links

  • Absolute [text for link](http://url.to.site)
  • Relative [text for link](relative_url)
  • With title [text for link](relative_url "my title")

Reference links

  • [text for link][anders]
  • Same text and id [anders][]

The referenced link ids must be defined somewhere else in the document like this:

[anders]: http:/anders.janmyr.com "Optional title"

The link definitions are inserted into the actual links and removed after the page is processed.

Automatic links

URLs surrounded with angle brackets <> are automatically inserted as links this may be used both for links and email:

  • <anders.janmyr@email.com>
  • <http://anders.janmyr.com>

Images

Images are inserted with link syntax, preceded with an exclamation point !.

  • ![Alt text](/path/to/img.jpg)
  • ![Alt text](/path/to/img.jpg "Optional title")
  • ![Alt text][id]

Escapes

Most of the Markdown special characters such as * and - may be escaped by preceding them with a backslash \.

1 comment:

Anonymous said...

Dear Author anders.janmyr.com !
Quite right! Idea excellent, it agree with you.