Markdown Guide - basic grammar

Overview
Almost all engines support Markdown Markdown syntax of basic inventor John Gruber designed. But different Markdown processing engines are slightly different in the details of performance, the following will be introduced one by one.

Title
To create a title, then just use the pound sign # at the beginning, the number of wells number of the corresponding level title. For example, if you want to create a <h3> can be used by beginning three #: ### Title three. Use the pound title grammar called "ATX title" in CommonMark specification.

The Markdown
the HTML
rendering results
# a title
<h1> a title </ h1>
a header
## subheadings
<h2> subheadings </ h2>
subheadings
### three title
<h3> three The title </ h3>
three title
#### title four
<h4> four </ h4> The title
four title
###### five title
<h5> The title five </ h5>
five title
####### six title
<h6> title six </ h6>
six heading
title optional grammar
except ATX title, we can also use Setext title: with one or more of the next line of text, etc. = indicates a title number, a dash or more - showing two header.

The Markdown
the HTML
rendering results
a title
======
<h1 of> a title </ h1>
a title
subheadings
-----------------------
<H2> subheadings </ h2 >
subheadings
best practice title
ATX title is preferably used between passages separated by blank lines. Because some Markdown syntax engine does not recognize the lack of blank lines before and after the title.

✅ safe
❌ not safe
This is a paragraph.

# A title

Another paragraph.
This is a paragraph.
# One title
to another paragraph
after ATX pound title sure to add a space

✅ safe
❌ unsafe
# a title
# a title
try not to use Setext syntax to write the title, because Setext grammar only title wrote two
paragraphs
blank lines to separate text.

Markdown
HTML
rendering results
I like to use Markdown.

I will use Markdown to format all of my documents.
<p> I like to use Markdown.
<p> I will use Markdown to format all of my documents. </ p>
I like to use Markdown.

I will use Markdown to format all of my documents.
Best Practices paragraphs
beginning of a paragraph Do not use spaces or tabs (\ t that is the Tab key) to indent, or it may be rendered as a block of code.

✅ safe
❌ not sound
beginning not to indent.

Like this like to keep left-aligned.
The beginning of the indentation may be rendered as a block of code.
The paragraph beginning with "two spaces" on the Chinese traditional typesetting habits, you can use full-width spaces or HTML entity & emsp. Publishing articles in the field of science and technology is not recommended two spaces, left-justified paragraph ranking better
wrap
, if desired text wrap <br>, can add two or more spaces at the end of the text and then press Enter.

Markdown
HTML
rendering results
which is the first line.
This is the second line.
<p> This is the first row. <br> This is the second line. </ p>
This is the first row.
This is the second line.
Wrap the best practices
currently most Markdown engine will automatically newline \ n converted to <br>, namely soft wrap turn hard line. So at the end, although steadily, but may also cause two or more spaces in the wording of some minor problems: trailing spaces are not visible in the some editors; to accidentally press or press to cause habit of typesetting errors. These range from small problems that may come with <br> wrap is the safest approach, but this is not elegant. In addition, you can use the CommonMark specification at the end of the text backslash \ to wrap, but I do not recommend such an approach.

In summary, my advice is do not use trailing spaces, \ or <br>, because now almost all of the basic engine have been Markdown support soft wrapping turn hard for the trip.

Bold and emphasize
bold to bold face, italics emphasize the correspondence.

Bold
To make text bold, you can use two asterisks or two underscores __ ** wrap text to be bold.

Markdown
HTML
rendering results
to bold text ** ** about
the text <strong> bold </ strong> at
the text bold look
to bold text __ __ about
the text <strong> bold </ strong> about
the text bold look
bold best practices
in bold with an asterisk and underlined that the differences between before and after the asterisk can not use spaces, but underlined needed to be added.

✅ safe
❌ unsafe
asterisk ** bold ** do not need the space
without a space underlined bold __ __ invalid
stressed
to emphasize text, you can use an asterisk * underscore _ or a parcel to be emphasized text.

Markdown
HTML
rendering results
to text * * emphasize what
to emphasize text <em> </ em> at
the text to emphasize
the text _ _ emphasize what
the emphasized text <em> </ em> at
the text to emphasize
highlight best practices
and bold similar before and after the asterisk can not use spaces, but underlined needed to be added.

✅ safe
❌ unsafe
asterisk * stressed * No space
is no space underscore _ _ stressed invalid
bold and stressed
if you want to emphasize text in bold at the same time, you can use three asterisks *** or three parcels to be underlined ___ emphasized text.

The Markdown
the HTML
rendering results
exemplary and simultaneously emphasized in bold
while <strong> <em> bold and emphasized </ em> </ strong> example
while example emphasized in bold and
exemplary and emphasized in bold while
simultaneously <strong> <em> bold and emphasized </ em> </ strong> example
while example emphasized in bold and
exemplary and emphasized in bold while
simultaneously <strong> <em> bold and emphasized </ em> </ strong> examples
An example of both bold and emphasized the
example of bold and at the same time stressed that
while <strong> <em> bold and emphasized </ em> </ strong> sample
at the same time bold and emphasized examples
asterisk can not have spaces
An asterisk <strong> <em> can not </ em> </ strong> spaces
asterisk can not have spaces
blockquote
to create a block quote <blockquote>, then only add greater-than sign before the paragraph>.

 
> Forgive my life love of freedom uninhibited indulgence will fall Payouyitian
> betrayed ideals, who can
> Which would you were my only Payouyitian

Rendering results

Forgive my life, love of freedom uninhibited indulgence will Payouyitian fall
back on over, who are
what you would Payouyitian only were my
block references within the segment
, if desired segment if necessary, before staging a blank line plus a>.

 
> Today I, too cold at night to see Piao
> With the cooling of the chest drift afar
>
> catch the wind and rain, fog tell it anyway
> sky wide sea you and me

Rendering results:

Today I, too cold at night to see Piao
With a cooling pit of the stomach drift afar

Catch the wind and rain, fog tell it anyway
sky wide sea you and I
quote nested block
block references can be nested, add two numbers greater than >> before the paragraph represent two nested.

 
> Block quotations
>
>> nested block quotation

Block references contain other elements
block can contain references to most of the other syntax elements. CommonMark specification is defined as a reference block containing block, the block container can contain any block-level element and the line-level elements, that is a reference block may contain any other elements.

 
> ### title is a leaf block elements
>
> * First list item container block elements
> * the second is a list of items containing block elements
>
> ** bold ** and * emphasize * is a row-level elements.

Rendering results:

The title is a leaf block elements
list item First container block elements
list item the second is a container block elements
bold and stressed that the row-level elements.
List
list is divided into an ordered list and unordered list. Markdown list only contains a list of items in the elements, and the block list item references, are container pieces. That list items can contain any other elements.

Ordered list
ordered list can be created by Arabic numerals followed Or), incrementing numbers do not have to be continuous.

Markdown
HTML
rendering results
1. a list item
2 list item two

<ol> <li> a list item </ li> <li> list item two </ li> </ ol>
list item a
list item two
1. a list item
1. list item two

<ol> <li> a list item </ li> <li> list item two </ li> </ ol>
list item a
list item two
1. a list item
3. The two list item

<ol> <li> a list item </ li> <li> list item two </ li> </ ol>
list item a
list item two
unordered list
unordered list by a dash -, or asterisk * plus + to begin with, followed by a space behind the need to separate text.

Markdown
HTML
rendering results
- a list of items
- two list items

<ul> <li> a list item </ li> <li> list item two </ li> </ ul>
list item a
list item two
* list item a
* list item two

<ul> <li> a list item </ li> <li> list item two </ li> </ ul>
list item a
list item two
+ a list of items
+ list item two

<ul> <li> list item a </ li> <li> list item two </ li> </ ul>
list item a
list item two
list entries contain other elements
list items may contain any other elements such as paragraphs, block references, code blocks, pictures. Starting point is the use of characters to be included and the list item elements to the initial content "align."

List item contains a paragraph
 
* list item a
* list item two first paragraph

This is the second paragraph
* List item three

Rendering results:

A list item
list item two first paragraph

This second section is
a list of three items
list entry contains a block quote
 
* list item a
* list item two first segment

> is a second segment reference block
* list of three items

Rendering results:

A list item
list item two blocks of the first section and the second is a reference
list of three items
list items that contain blocks of code
 
* list item a
* list item two first paragraph

`` `
Here is the code block
echo Hello, world!
`` `
* List item three

Rendering results:

A list item
list item two first paragraph 
here is the code block
echo Hello, world!

List item three
list items that contain pictures
 
* list item a
* list item two first paragraph

! [B3log] (https://static.b3log.org/images/brand/b3log-128.png "B3log open source community")
* List item three

Rendering results:

A list item
list item two first paragraph


List item three
codes
code can be wrapped by back quotes `` `.

Markdown
HTML
rendering results
are listed in the file command is `ls`
listed in the file command <code> ls </ code>
list file ls command is
an escape backticks
if you need to display anti-quotation marks, you can use the escape character \ come to anti-quotes escaped.

The Markdown
the HTML
rendering results
make Backticks `
make backquote`
make backquote `
block
code blocks may be used or tabs 4 space indentation \ t indentation.

 
<html>
<head>
</head>
</html>

Rendering results:

 
<html>
<head>
</head>
</html>

Recommended fence block syntax layout code blocks, i.e., the use of `` `to wrap the code block, and specifies the language syntax highlighting:

 
```html
<html>
<head>
</head>
</html>
```

The dividing line
by not less than three asterisks ***, dashes or underscores ___ --- to create a separator line.

 
***
---
___

Rendering results:


Hyperlink
to create a hyperlink by [link text] (URL).

 
We come from a small minority of the open source community [B3log] (https://b3log.org).

Rendering results:

We come from a small minority of the open source community B3log.

Add hyperlinks title
link title is optional, the URL in parentheses wrapped in double quotes. Move the mouse over the title will display the contents of floating on the link.

 
We come from a small minority of the open source community [B3log] (https://b3log.org "B3log open source").

Rendering results:

We come from a small minority of the open source community B3log.

URL and e-mail address
if you want to directly display URL or e-mail address, you can <and> to wrap the URL or email address.

 
<https://b3log.org>

<[email protected]>

Most Markdown engine also supports the automatic conversion, so can save <>:

 
https://b3log.org

[email protected]

Typesetting format hyperlinks
Hyperlinks can be bold and emphasized that the code structure used with other elements.

 
We come from a small minority of the open source community ** [B3log] (https://b3log.org) ** .
We come from a small minority of the open source community [ `B3log`] (https://b3log.org).

Rendering results:

 

Author: 88250
Link: https: //hacpai.com/article/1583129520165
Source: Hackers send
protocol: CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/

Guess you like

Origin www.cnblogs.com/sunofwe/p/12395989.html