当前位置:网站首页>Markdown skill tree (8): code blocks
Markdown skill tree (8): code blocks
2022-06-29 07:27:00 【programmer_ ada】
Markdown The skill tree (8): Code block
The format of the inline code is simple , Just use two ` Just wrap the code content , such as var foo = 'bar';
Indent to show code
To be in Markdown It is also easy to create code blocks in , Simply indent 4 Blank or 1 individual tab Can , for example , The following input :
This is an ordinary paragraph :
This is a code block.
stay Markdown Will be converted into a :
<p> This is an ordinary paragraph :</p>
<pre><code>This is a code block.
</code></pre>
This indent is one level per line (4 Blank or 1 individual tab), Will be removed , for example :
Here is a sample code :
tell application "Foo"
beep
end tell
Will be converted to :
<p> Here is a sample code :</p>
<pre><code>tell application "Foo"
beep
end tell
</code></pre>
A block of code will continue until the line without indentation ( Or at the end of the document ).
In the code block , & 、 < and > It will automatically change to HTML Entity , This way it's very easy for you to use Markdown Insert HTML The original sample code for , for example :
<div class="footer">
© 2004 Foo Corporation
</div>
Will be converted to :
<pre><code><div class="footer">
&copy; 2004 Foo Corporation
</div>
</code></pre>
Highlight snippet
In addition to indenting code snippets ,Markdown It also supports highlighted code snippets , When creating a highlighted snippet , Put the code snippet by with three backquotes ( ``` ) Line up , And mark the language type at the end of the first fence , such as :
// A highlighted block
var foo = 'bar';
```javascript
// A highlighted block
var foo = 'bar';
```
You can also leave the language type unspecified , such as
echo "Hello"
```
echo "Hello"
```
Diff grammar
Besides ,Markdown And support Diff Highlight syntax , The format is as follows
var foo = 'bar';
- var x = 200;
+ var x = 100;
```diff
var foo = 'bar';
+ var x = 200;
* var x = 100;
```
It should be noted that , If the difference content contains `, Make sure you use backslashes \ To escape each backquote ` , Otherwise, the difference highlighting will not appear correctly .
Summary
Let's review Code block The knowledge of it :
- With two ` Wrapping the content of the code is an inline code
- Indent 4 Blank or 1 individual
tabYou can create an indented code block - Use three backquotes before and after the code block ( ``` ) Wrap the code that needs to be highlighted , And in the first ``` You can create a highlighted code block by marking the language type at the end of the
边栏推荐
- SAP UI5 初学 ( 一 )、简介
- Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
- National Security Agency and CISA kubernetes reinforcement guidelines - new content in version 1.1
- 数字ic设计——UART
- Spark RDD案例:统计每日新增用户
- SYSTEMd management node exporter
- uva10635
- And check the collection hello
- Markdown 技能树(9):表格
- Markdown 技能树(7):分隔线及引用
猜你喜欢
随机推荐
NoSQL数据库之Redis(四):Redis新数据类型
Spark RDD案例:统计每日新增用户
uva11825
Effective methods for construction enterprises to select smart construction sites
LSTM神经网络和普通神经网络的使用
测试人员需要了解的工具有哪些
Utilisation d'IPv6 pour réaliser l'accès public au bureau distant
Do you really understand "binder copy once"?
Deploy Prometheus server service system management
[qnx hypervisor 2.2 user manual]6.2.1 communication between guests
示波器 符号
Crawler data analysis (introduction 2-re analysis)
利用Jsonp跨域请求数据
LeetCode_动态规划_中等_91. 解码方法
[translation] [Chapter II ①] mindshare PCI Express technology 3.0
NoSQL數據庫之Redis(五):Redis_Jedis_測試
CI工具Jenkins安装配置教程
项目中 if else 的代替写法
Golang modifying the value of a structure slice
Introduction to NoSQL database






