PHP and Javascript implementations of a simple markdown parser
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

markdown.md 5.5KB

Markdown Syntax

(todo: include class names for enabling these features)

Block Formats

Formats that apply to one or more lines.

Paragraph

Any contiguous set of lines not formatted like one of the other formats below is treated as a paragraph. Paragraphs are separated by double blank lines.

Lorem ipsum dolor
sit amet.

New paragraph begins.

Headers

Headers are marked with one or more leading hashes.

# Header 1 has one hash

## Header 2 has two hashes

###### Up to header 6

## Optional Matched Hashes At The End ##

Alternately, H1 and H2 can be marked with underlines.

Header 1 underlined with equals
===============================

Header 2 with hyphens. Number of underline chars doesn't matter
---

Lists

Unordered lists are bulleted with an asterisk, plus, or hyphen and space.

* Item
+ Any of these
- Work as bullets

Lists can be nested with one or more spaces below an item.

* Item
    * Sublist
	* Sublist
* Item

Ordered lists start with a number, period, and space.

1. Item
2. Item
3. Item

Again, they can be nested.

1. Item
    1. Subitem
	2. Subitem
2. Item

The first number dictates where the numbering begins. The numbers on the other items are ignored and incremented by one.

5. Rendered as a 5
1. Rendered as a 6
1. Rendered as a 7

Blockquote

Blockquotes enclose lengthy quoted content in an indented block.

Lorem Ipsum said:

> Dolor sit amet
> adipiscing.

Code Blocks

Blocks of preformatted code can be enclosed in triple backticks.

`​``
function foo() {
	return 'bar';
}
`​``

Alternately, lines indented by at least four spaces or a tab character will be interpreted as code blocks.

    function foo() {
		return 'bar';
	}

Horizontal Rule

Horizontal divider lines are written as 3 or more hyphens or asterisks on a line by themselves, with or without interstitial whitespace.

---

***

- - - -

* * * * * * *

Tables

Tables consist of one header row and any number of body rows

Header   | Row | Here
---------|-----|-----
Cell     | 123 |  xyz
Next row | 543 |  abc

The pipe characters do not have to line up.

Rows can optionally have leading and/or trailing pipes. This is required for a single column table.

| One column |
| --- |
| 123 |
| 234 |

Columns can be right, center, or left aligned with colons in the divider line.

| Left | Center | Right |
| :--- | :----: | ----: |
| 1 | 2 | 3 |

Definition List

Definition lists show terms with definitions below them. Useful for glossaries.

term
: definition of term
another
: definition of another
: alternate definition of another

Abbreviation Definition

Abbreviations can be defined anywhere in the document. Anywhere that abbreviation appears in the document will have a mouseover title showing the expanded definition. The definition is plaintext only (no markdown).

*[ABC]: Always Be Closing

CSS Modifiers

Many block structures can be modified with CSS classes, IDs, or other simple HTML attributes inside curly braces.

# Header {.mycssclass}

--- {#mydividerid}

| Table | {style=color:green;}
|---|
|123|

# Multiple Modifiers {.linkclass #linkid lang=en}

Inline Formats

Formats that apply within a block to style runs of words or inject other content within text.

Strong

Text can be marked as bold by enclosing it in double asterisks.

Some **bold** text. Can also use __underscores__.

Emphasis

Text can be marked as italic by enclosing it in single underscores or single asterisks.

Some _italic_ text. Can also use *asterisks*.

Strikethrough

Text can be stricken out using tildes, singly or in pairs.

Not ~~this text~~. Not ~this text~ either.

Code

Words can be rendered in monospace font using single backticks.

The name of the function is `foo()`.

Link

Linking to a document is done with marked text and a URL.

Click [here](page.html).

An optional mouseover title can be added to the link after the URL.

Click [here](page.html "Goes to a neat page").

Repetitive or lengthy URLs can be referenced out and defined elsewhere in the document.

Click [here][foo] or [here][foo] or [even here][foo] to go to the same place.

[foo]: page.html "Optional title"

Lastly, to make a link with the URL as the link text, you can use angle brackets.

Go visit <page.html>.

Image

An image is similar to link syntax with an exclamation in front. Instead of clickable link text, the text is alt text for the image.

![a test image](https://picsum.photos/100/75)

Images also support title attributes.

![a test image](https://picsum.photos/100/75 "title text")

Images also support referenced URLs.

![alt text][foo]

[foo]: https://picsum.photos/100/75

Images can be made clickable by enclosing them in a link where the link text goes.

[![alt text](image.jpg)](page.html)

Footnote

Footnotes can be inserted into text. The text of the footnotes is added to the bottom of the document, regardless of where they’re defined.

Lorem ipsum[^1] dolor sit[^2] amet.

[^1]: Further information here
[^2]: See _Interesting Book_, pg 213

HTML Tags

Currently all HTML tags and attributes are permitted, when markdown syntax doesn’t do what you want.