Markdown est un langage de balisage (markup langage en anglais). Un peu à la manière du HTML, il permet de formatter le texte via un système d’annotations. Le Markdown se veut facile à lire, y compris dans sa version texte, et il est donc plus instinctif à apprendre. Il est souvent supporté par les systèmes de commentaires, chats et forums.
Exemple de syntaxe Markdown :
# Titre
Du *texte en italique*, **en gras**.
* Une liste
* d'items
``` js
function hello() {
alert("Hello");
}
```
En général, un fichier Markdown a l’extension .md
ou .markdown
.
Il existe différents parser Markdown, chacun apportant quelques nuances et fonctionnalités différentes. Par exemple, certains parser acceptent les tags HTML, implémentent les tables, les attributs de bloc (classe, id, etc).
La syntaxe décrite ci-dessous est la syntaxe supportée par Github, dite Github Flavored Markdown (GFM). Le parser utilisé par Github est CommonMark. Voir les specs. Voir fichier test
Avant | Après |
---|---|
# h1 Heading | h1 Heading |
## h2 Heading | h2 Heading |
### h3 Heading | h3 Heading |
#### h4 Heading | h4 Heading |
##### h5 Heading | h5 Heading |
###### h6 Heading | h6 Heading |
This is an H1 ============= | This is an H1 |
This is an H2 ------------- | This is an H2 |
La syntaxe Markdown de formattage de texte n’est pas interprétée à l’intérieur d’un pre
.
Pour formatter du texte à l’intérieur d’un pre
, utiliser des balises HTML.
pre
Avant | Après |
---|---|
**This is bold text** | This is bold text |
__This is bold text__ | This is bold text |
*This is italic text* | This is italic text |
_This is italic text_ | This is italic text |
~~Strikethrough~~ | |
\*Literal asterisks\* | *Literal asterisks* |
pre
Avant | Après |
---|---|
<strong>This is bold text</del> | This is bold text |
<em>This is italic text</em> | This is italic text |
<del>Strikethrough</del> | |
<s>Strikethrough</s> | |
<ins>Underline</ins> | Underline |
Indice <sub>sub</sub> | Indice sub |
Exposant <sup>sup</sup> | Exposant sup |
© | © |
➤ | ➤ |
Avant | Après |
---|---|
Les retours à la ligne en fin de ligne |
Les retours à la ligne en fin de ligne sont ignorés |
Ajouter deux espaces à la fin |
Ajouter deux espaces à la fin |
Ou séparer les lignes |
Ou séparer les lignes D'une ligne vide |
Avant | Après |
---|---|
Inline <code>code</code> | Inline code |
Inline `code` | Inline code |
Non interpreted <i>block code (4 spaces)</i> |
|
<pre> Interpreted <i>block code</i> </pre> |
Interpreted block code |
``` Non interpreted <i>block code</i> ``` |
|
<pre lang="diff"> diff --git a/filea.extension b/fileb.extension index d28nd309d..b3nu834uj 111111 --- a/filea.extension +++ b/fileb.extension @@ -1,6 +1,6 @@ -oldLine +newLine </pre> |
|
``` js var foo = function (bar) { return bar++; }; ``` |
|
<kbd>Ctrl</kbd> + <kbd>S</kbd> | Ctrl + S |
Avant | Après |
---|---|
> Blockquote Still blockquote Again >> sub-blockquote > > > sub-sub blockquote. |
|
Syntaxe interprétée à l’intérieur d’un pre
Avant | Après |
---|---|
![Alt](https://placehold.it/50x50) | |
![Alt](https://placehold.it/50x50 “title”) | |
![Alt][id_img] [id_img]: https://placehold.it/50x50 |
Syntaxe interprétée à l’intérieur d’un pre
Avant | Après |
---|---|
http://google.com | http://google.com |
[Text](http://google.com) | Text |
[Text](http://google.com “title”) | Text |
[Text][id_link] [id_link]: http://google.com “optional title” |
Text |
h​ttp://google.com | http://google.com |
Avant | Après |
---|---|
* Item 1 With content * Item 2 (2 spaces) With content + Item 1 + Item 2 - Item 1 - Item 2 |
|
Avant | Après |
---|---|
1. Item 1 2. Item 2 3. Item 3 * Item 3a * Item 3b 1. Item 4 The number doesn't really matter 1. Item 5 2. Item 6 2. Item 7 |
|
Avant | Après |
---|---|
- [x] This is a complete item - [ ] This is an incomplete item |
- [x] This is a complete item - [ ] This is an incomplete item |
Avant | Après |
---|---|
1. Item 1 1. Item 2 <!-- --> 1. Une autre liste ! |
|
Avant | Après |
---|---|
du texte avant 1. Item 1 du texte après |
du texte avant
|
du texte avant * Item 1 du texte après |
du texte avant
|
Avant | Après |
---|---|
___ | |
--- | |
*** |
Avant | Après | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Default | Align left | Align center | Align right | | --- | :--- | :---: | ---: | | A | B | C | E | | F \| G | H | I | J | |
|
Avant | Après |
---|---|
:sparkles: :camel: :boom: | :sparkles: :camel: :boom: |
Liste complète des emojis : http://www.emoji-cheat-sheet.com/ (Github)
<details>
<summary>Click here to expand.</summary>
<br>
The content of the div
</details>