当前位置:网站首页>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
边栏推荐
- BeanPostProcessor 和 BeanFactoryPostProcessor
- systemd 管理node-exporter
- Two ways to write throttling - recently seen
- 什么是测试架构师
- Suggestions on digital transformation of large chemical enterprises
- NoSQL数据库之Redis(四):Redis新数据类型
- IMX6DL4.1.15支持EIM总线(下)——配置原理分析。
- LeetCode_动态规划_中等_91. 解码方法
- What does VPS do? What are the famous brands? What is the difference with ECS?
- Redis de la base de données nosql (v): redis Jedis Tests
猜你喜欢

YGG cooperated with Web3 platform leader to empower the creative community with Dao tools and resources

通过keyup监听textarea输入更改按钮样式

Uniapp obtains the date implementation of the beginning and end of the previous month and the next month

The meaning and calculation method of receptive field

关联性——相关性分析

机器学习笔记 - 时间序列的混合模型
什么是测试架构师

Solve the problem that NPM does not have permission

电子商务盛行,怎么提高商店转换率?

【FreeRTOS】中断机制
随机推荐
关于工作方法和高效工作的建议
uva10859
期末总结——Spark
TREE ALV 展开Node或者点击Toolbar按钮时DUMP(CL_ALV_TREE_BASE==============CP|SET_ITEMS_FOR_COLUMN)
NoSQL数据库之Redis(一):安装 & 简介
Idea integrated code cloud
uva10859
[QNX Hypervisor 2.2用户手册]6.2.1 Guest之间通信
Beanpostprocessor and beanfactorypostprocessor
Markdown 技能树(5):图片
[translation] [Chapter 2 ②] mindshare PCI Express technology 3.0
Utilisation d'IPv6 pour réaliser l'accès public au bureau distant
Chinese garbled code on idea console [valid through personal test]
详解Autosar Arxml中的CANFD报文及格式
Shift/space studio "Aurora" project: building a villa in the sandbox metauniverse
jmeter 用beanshell导入自己jar包老是查找不到
Summary of some new datasets proposed by cvpr2021
uva11825
When the soft keyboard appears, it makes my EditText field lose focus
uva10891