Fundamentals of Markdown grammar

Keywords: markdown

The Markdown syntax included in this article is:

  • title
  • written words
  • Bold Italic
  • Scribe
  • footnote
  • paragraph
  • Line feed
  • Separator
  • list
  • block quotations
  • code
  • link
  • picture
  • form
  • catalogue
  • notes
  • Supported HTML elements
  • Escape character

title

In Markdown, the title can be displayed in two ways

  • One is to use = or-
  • One is to use#

1. Use = or-

Use at least three = or-

Code example:

Primary title
===
Secondary title
---

2. Use#

Add # in front of the text you want to set as the title

  • #Add a space after it
  • One # is the primary title, the other # is the secondary title, and so on. Six level titles are supported.

Code example:

# Primary title
## Secondary title
### Tertiary title
#### Four level title
##### Five level title
###### Six level title

written words

Bold Italic

In MarkDown, there are two ways to write in bold and italics, one is with *, the other is with_ Wrap what you want to change

In * or_ Keep close to the content, and do not use spaces before

  • One * or one_ It's in italics
  • Two * or two_ It's bold
  • Three * or three_ Is bold italic

Code example:

*Italic text*          _Italic text_
**Bold text**        __Bold text__
***Bold italic text***    ___Bold italic text___

Example effect:

Italic text
Bold text
Bold italic text

Scribe

In MarkDown, there is no self syntax of underline and underline, only the syntax of strikeout (middle underline), but it can be implemented in other ways

  • The upper dash line can be realized by Latex formula
  • Strikethrough (middle dash)
  • Underline is implemented using HTML syntax or Latex formula

Code example:

<!--adopt Latex Formula implementation upper dash-->
$\overline{\text{Upper scribe}}$

~~Delete line~~

<!--adopt Latex Formula implementation underline-->
$\underline{\text{Underline}}$

<!--adopt HTML Label implementation underline-->
<u>Underline</u>

Example effect:

<!-- The upper dash line is realized through Latex formula -- >
$\ outline {\ text {overline}}$

Delete line

<!-- Underline through Latex formula -- >
$\ underline{\text {underline}}$

<!-- Underline through HTML tags -- >
<u> Underline < / u >

footnote

In MarkDown, the method of adding footnotes is supported to supplement the text.

Add the footnote name after the text to which you want to add a footnote: 1 . Then add a footnote anywhere in the text (usually at the end):

Footnotes are automatically generated at the back of the page, which can be seen at the end of the page, and the links behind footnotes can directly jump back to the place where footnotes are added.

Code example:

Footnote example, this is the first footnote[^Footnote name 1],This is the second footnote[^Footnote name 2],This is the third footnote[^Footnote name 3]
[^Footnote name 1]:I'm footnote one.
[^Footnote name 2]:I'm footnote two.
[^Footnote name 3]:I'm footnote three.

Example effect:

Footnote example, this is the first footnote 2 , this is the second footnote 3 , this is the third footnote 4

paragraph

Line feed

There is no special format in the Markdown paragraph

  • When the content needs to wrap, use more than two spaces and enter.
  • When you need to generate a new paragraph, just leave one line blank

Multiple blank lines only one blank line is effective

Code example:

Previous line
 Next line

Previous paragraph  

Next paragraph

Example effect:

Previous line
Next line

Previous paragraph

Next paragraph

Separator

In the Markdown separator, you need to use * or - or_ To build

  • *Or - or_ Three or more are required
  • *Or - or_ You can insert a space in the middle, but you cannot have anything else in the line
  • *Or - or, When there are paragraphs after the current one, please leave one line blank

Code example:

---

- - -

___

_ _ _

***

* * *

Example effect:

    • -

_

_

list

Unordered list

The contents of the list can be preceded by * or - or + spaces to represent an unordered list

Code example:

- Unordered list items, using `-` + `Space`
+ Unordered list items, using `+` + `Space`
* Unordered list items, using `*` + `Space`

Example effect:

  • Unordered list items, using - + spaces
  • Unordered list items, using + + spaces
  • Unordered list items, using * + spaces

Ordered list

Numbers + spaces can be used before the contents of the list to represent an ordered list

The ordered list will automatically add numbers to your list items in Arabic numerical order

Code example:

1. First item
2. Item 2
4. Item 3

Example effect:

  1. First item
  2. Item 2
  3. Item 3

List nesting

Add four spaces before the list item in the sublist

Code example:

1. First item in ordered list A
    - A The first entry of has no sequence table children a1
        1. a1 The first item of has sequence table children a1a
        1. a1 The second item of has a sequence table sub item a1b
    - A The second item of has no sequence table subitems a2
2. First item in ordered list B
    B First line of text content
    B Second line of text content

Example effect:

  1. Ordered list first item A

    • The first item of a has no sequence table sub item a1

      1. The first item of a1 has a sequence table sub item a1a
      2. The second item of a1 has a sequence table sub item a1b
    • The second item of a has no sequence table sub item a2
  2. Ordered list first item B
    Text content of the first line of B
    Text content of the second line of B

block quotations

Simple block reference

Use > + spaces in Markdown to represent block references

When you need to wrap a line, you can leave >
If you need a new plate, you can leave a row

Code example:

> Line breaks can be omitted `>`
 Not in front of me `>`

> If a new block is needed, the block reference is left blank and reused in front of the text `>`

Example effect:

You can wrap without >
There is no >

If a new block reference is needed, leave a line blank and use >

Nesting of block references

In Markdown, block references can also be nested by using multiple >

The number of > used by nested block references represents the nesting depth
The > in nested block references can be separated without spaces

Code example:

>> The second floor

> first floor
> > The second floor

> first floor
> > > Third floor

Example effect:

The second floor

first floor

The second floor

first floor

Third floor

Block references and lists

In Markdown, block references can be used in the list, and lists can also be used in block references

Lists can also be nested lists, and block references can also be nested blocks (this chapter only gives a brief introduction)

  • Use block references in lists

Code example:

1. Ordered list A
    > block quote 
    1. Ordered list Aa
        > block quote 
    > block
2. Ordered list B 

Example effect:

  1. With sequence table A

    block quote

    1. Ordered list Aa

      block quote
      block

  2. With sequence table B
  • List used in block references

Code example:

> - This is an ordered list A
> - Unordered list B
>     * Sub list needs to be in `>` Add four spaces after 

Example effect:

  • This is list A
  • Unordered list B

    • The sub list needs four spaces after >

code

It is recommended that the Shell command with output content be preceded by $, which will not confuse the command with the output content

  • Code snippet

Code snippets can be wrapped with a pair of backquotes \ ` \ `

Code example:

Use in text segments`Code snippet`,Just wrap it in reverse quotation marks

Example effect:

If you use code snippets in text snippets, wrap them in back quotes

  • Code block

      - Add 4 spaces before each line of text
      - Add 1 before each line of text<kbd>tab</kbd>key
      - Use three backquotes```Package a piece of code in the first one```Later, you can specify the code language to highlight the code, or you can not specify the language
    

Wrap the code block in three quotation marks, which are placed first

Code example:

    I use 4 spaces to form a code block
    I use one<kbd>tab</kbd>Key to form a bad code block
markdown code  
# title
1. Ordered list
```
___Example effect:___

---

    I use 4 spaces to form a code block
    I use one<kbd>tab</kbd>Key to form a bad code block

markdown code

title

  1. Ordered list

    ---
    
    ## link
    
    stay Markdown In, links can be used to variables
  2. Simple link

    • [link name] (link URL)
    • [link name] (link URL "text description")
    • < link URL >

    The text description can be viewed by hovering the mouse over the link

    Code example:

    Baidu[Baidu](https://www.baidu.com/)
    Baidu[Baidu](https://www.baidu.com/ "Baidu search")
    Baidu<https://www.baidu.com/>

    Example effect:

    Baidu Baidu
    Baidu Baidu
    Baidu https://www.baidu.com/

  3. Advanced links

    You can use variables to invoke links

    When using variables, remember to assign values to variables at the end of the document

    Code example:

    [Baidu][1]
    [Google][2]

Then assign a value (URL) to the variable at the end of the document

___Example effect:___

---

[Baidu][1]
[Google][2]

Then assign a value (URL) to the variable at the end of the document

[1]: https://www.baidu.com/
[2]: http://www.google.com/

---


## picture

The difference with the link method is that it is preceded by an exclamation point ` ! `

* `[Picture upload failed...(image-caa9b7-1632883183326)]`
* `[Picture upload failed...(image-4d432f-1632883183327)]`
* `You can also use variables like links[Baidu][1].`

Then assign a bit variable (URL) at the end of the document

[1]: https://www.baidu.com/

__

___Code example:___

! [Baidu logo]]( https://www.baidu.com/img/PCt...)

Baidu

___Example effect:___

---

![Baidu logo](https://upload-images.jianshu.io/upload_images/26609212-9378a73477b77248.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![Baidu](https://Upload-images.jianshu.io/upload_images / 26609212-5240f8634959c454.png? Imagemogr2 / Auto orient / strip% 7cimageview2 / 2 / w / 1240 "Baidu logo")

[Baidu][1]

[1]: https://www.baidu.com/

---

## form

stay Markdown Use in making tables | To separate different cells, use - To separate the header from other rows.

Table alignment
* -: Set the right alignment of content and title bar.
* :- Set the left alignment of content and title bar.
* :-: Center the content and title block.

_Table alignment is written in the row below the header `----` in_

___Code example:___
Header IAlign leftCenter itAlign right
Cell 1Cell 2Cell 3Cell 4
Cell 11Cell 22Cell 33Cell 44
Cell 111Cell 222Cell 333Cell 444
Cell 1111Cell 2222Cell 3333Cell 4444
___Example effect:___

---

|  Header I   | Align left  |  Center it  |   Align right  |
| :----- | :-----| :----: | ----: |
| Cell 1 | Cell 2 | Cell 3 | Cell 4 |
| Cell 11 | Cell 22 | Cell 33 | Cell 44 |
| Cell 111 | Cell 222 | Cell 333 | Cell 444 |
| Cell 1111 | Cell 2222 | Cell 3333 | Cell 4444 |

---

## catalogue

Place a tag where you want the directory to appear (usually at the beginning of the article), which will automatically generate a nested list containing all titles.

_If there are spaces in the corresponding headings , Use in anchor links`-`Replace spaces_

___Code example:___

This article catalog example

*5 : note, not displayed
*[@#@]: comment, not displayed

___Example effect:___

---

Comments are written below, but will not be parsed and rendered. Different parsers support different results.
<!--Notes, not displayed-->
[comment]: <> (Notes, not displayed)
[//]: < > (note, not displayed)
[//]: # (note, not shown)
*[^_^]:Notes, not displayed
*[@_@]:Notes, not displayed
 
---

#### Supported html elements

Currently supported HTML The elements are:`<kbd> <b> <i> <em> <sup> <sub> <br>`etc.
_be not in Markdown Labels within the scope can be used directly in the document HTML compose._

___Code example:___

tab key
bold
Italics
Also in italics
Text superscript
Text subscript
Line feed
next row

<details>

<summary>Click to view</summary>
Here is the folded content

</details>
There are many other html tags, which are not listed here

___Example effect:___

---

<kbd>tab</kbd>key
<b>bold</b>
<i>Italics</i>
<em>Also in italics</em>
text<sup>Superscript</sup>
text<sub>subscript</sub>
Line feed<br>next row

<details>
    <summary>Click to view</summary>
    Here is the folded content
</details>
There are many others html Labels are not listed here...

---

#### Escape character

stay Markdown Many special symbols are used in. If you need to display specific symbols, you need to use escape characters. You can use backslashes`\`To escape

___Markdown Backslash escape table___

| Escape character | Chinese name |    English name |
| :-----: | :-----:| :----: |
| \    | Backslash | backslash    |
|`    | backquote  | backtick    |
|*    | asterisk | asterisk |
|_    | Underline | underscore |
|{}    | Braces | curly braces |
|[]    | square brackets | square brackets |
|()    | brackets | parentheses |
|#    |Well No. | hash mark|
|+    | plus | plus sign |
|-    | Minus sign (hyphen)| minus sign (hyphen) |
|.    | decimal point | dot |
|!    |exclamatory mark| exclamation mark    |

___Code example:___

\Backslash
\`Backquote
*Asterisk
\_ Underline
{} curly braces
[] square brackets
() parentheses
\#Well size
+Plus sign
-Minus sign
English period
\! exclamatory mark

___Example effect:___

---

\\   Backslash
\`   backquote 
\*   asterisk
\_   Underline
\{}  Curly bracket
\[]  square brackets
\()  parentheses
\#   Well size
\+   plus
\-   minus sign
\.   English period
\!   exclamatory mark
  1. Footnote name
  2. I'm footnote 1, which can be followed by a link to the footnote position.
  3. I'm footnote 2. You can return to the link where the footnote is added later.
  4. I'm footnote 3. You can return to the link where the footnote is added later.
  5. _^

Posted by fishown on Fri, 19 Nov 2021 21:42:36 -0800