Fundamentals of Markdown grammar

Posted by mark110384 on Wed, 29 Sep 2021 05:39:03 +0200

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 mark down, there are two ways to write in bold and italics. One is to use  * , One is to use  _  Wrap what you want to change

stay  *  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 Using HTML syntax or   Implementation of 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:

$\ outline {\ text {overline}}$

Delete line

$\ underline{\text {underline}}$

Underline

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: [^ footnote name]. 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 [1] , this is the second footnote [2] , this is the third footnote [3]

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

The Markdown delimiter needs to be used  *  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

Available before list content  *  or  -  or  + +  Space 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  - +  Space
  • Unordered list items, using  + +  Space
  • Unordered list items, using  * +  Space

Ordered list

Available before list content   Number + space 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 in Markdown  > +  Space   To represent a block reference

When you need to wrap a line, you can leave it blank in front  >
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:

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  >

Nesting of block references

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

Nested block reference usage  >  The number of represents the nesting depth
Nested block reference  >  There can be no spaces between them

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
    • Sub list needs to be in  >  Add 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
    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

In Markdown, links can use variables

  • 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 Baidu once, you know

  • 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

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

Example effect:

Baidu
Google

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

picture

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

  • [image upload failed... (image-caa9b7-1632883183326)]
  • [image upload failed... (image-4d432f-1632883183327)]
  • You can also use the variable [Baidu] [1] like a link

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

__

Code example:

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

![Baidu](https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png "Baidu logo")

[Baidu][1]

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

Example effect:

Uploading... Re upload cancel

Uploading... Re upload cancel

Baidu

form

Make tables in Markdown, use | to separate different cells, and - to separate headers and other rows.

Table alignment

  • -: set the right alignment of content and title bar.
  • : - align the content and title bar to the left.
  • : -: center the content and title block.

Table alignment is written in the row below the header  ----  in

Code example:

|  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 |

Example effect:

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

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 titles at all levels, use - instead of spaces in the anchor link

Code example:

This article catalog example
- [title](#(title)
- [written words](#(text)
    - [Bold Italic](#Bold (italics)
    - [Scribe](#(scribe)
    - [footnote](#Footnote)
- [paragraph](#Paragraph)
    - [Line feed](#Line feed)
    - [Separator](#(separator)
- [list](#(list)
    - [Unordered list](#Unordered list)
    - [Ordered list](#Ordered list)
    - [List nesting](#List (nested)
- [block quotations ](#Block reference)
    - [Simple block reference](#Simple block reference)
    - [Nesting of block references](#(nesting of block references)
    - [Block references and lists](#Block references and lists)
- [code](#(code)
- [link](#(link)
- [picture](#(picture)
- [form](#Table)
- [catalogue](#Table of contents)
- [Advanced skills](#Advanced skills)
    - [notes](#(note)
    - [Supportive html element](#Supported html elements)
    - [Escape character](#Escape character)

Example effect:

This article catalog example

Advanced skills

notes

In Markdown, comments can be customized

  • You can use html syntax to comment <-- Haha, I'm a comment and won't be displayed in the browser. -- >
  • You can use * [· - ·]: annotation content format for annotation, where the content in [] can be customized

These comments are not valid in the code snippet. Comments in the code block are based on the specified language

Code example:

<!--Notes, not displayed-->
[comment]: <> (Notes, not displayed)
[//]: < > (note, not displayed)
[//]: # (note, not shown)
*[^_^]:Notes, not displayed
*[@_@]:Notes, not displayed

Example effect:

Comments are written below, but will not be parsed and rendered. Different parsers support different results.

Supported html elements

Currently supported HTML elements are: < KBD > < b > < I > < EM > < sup > < sub > < br >
Tags not covered by Markdown can be written directly in HTML in the document.

Code example:

<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...

Example effect:

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

Click to view

There are many other html tags, which are not listed here

Escape character

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

Markdown backslash escape table

Escape characterChinese nameEnglish name
\Backslashbackslash
`backquote backtick
*asteriskasterisk
_Underlineunderscore
{}Bracescurly braces
[]square bracketssquare brackets
()bracketsparentheses
#Well numberhash mark
+plusplus sign
-Minus sign (hyphen)minus sign (hyphen)
.decimal pointdot
!exclamatory markexclamation mark

Code example:

\\   Backslash
\`   backquote 
\*   asterisk
\_   Underline
\{}  Curly bracket
\[]  square brackets
\()  parentheses
\#   Well size
\+   plus
\-   minus sign
\.   English period
\!   exclamatory mark

Example effect:

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

  1. I'm footnote 1, which can be followed by a link to the footnote position.   ↩︎

  2. I'm footnote 2. You can return to the link where the footnote is added later.   ↩︎

  3. I'm footnote 3. You can return to the link where the footnote is added later.   ↩︎