Markdown代码块语法高亮显示

本文详细介绍了一种代码高亮方案,支持多种编程语言,包括但不限于C、Python、JavaScript等,展示了不同语言的代码示例及其高亮效果,适用于各种编程场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

语言支持

名称关键字调用的js说明
AppleScriptapplescriptshBrushAppleScript.js
ActionScript 3.0actionscript3 , as3shBrushAS3.js
Shellbash , shellshBrushBash.js命令行操作,git操作
ColdFusioncoldfusion , cfshBrushColdFusion.js
Ccpp , cshBrushCpp.js
C#c# , c-sharp , csharpshBrushCSharp.js
CSScssshBrushCss.js
Delphidelphi , pascal , passhBrushDelphi.js
diff&patchdiff patchshBrushDiff.js用代码版本库时,遇到代码冲突,其语法就是这个.
Erlangerl , erlangshBrushErlang.js
GroovygroovyshBrushGroovy.js
JavajavashBrushJava.js
JavaFXjfx , javafxshBrushJavaFX.js
JavaScriptjs , jscript , javascriptshBrushJScript.js
Perlperl , pl , PerlshBrushPerl.js
PHPphpshBrushPhp.js
texttext , plainshBrushPlain.js就是普通文本.
Pythonpy , pythonshBrushPython.js
Rubyruby , rails , ror , rbshBrushRuby.js
SASS&SCSSsass , scssshBrushSass.js
ScalascalashBrushScala.js
SQLsqlshBrushSql.js
Visual Basicvb , vbnetshBrushVb.js
XMLxml , xhtml , xslt , htmlshBrushXml.js
Objective Cobjc , obj-cshBrushObjectiveC.js
F#f# f-sharp , fsharpshBrushFSharp.js
xpp , dynamics-xppshBrushDynamics.js
Rr , s , splusshBrushR.js
matlabmatlabshBrushMatlab.js
swiftswiftshBrushSwift.js
GOgo , golangshBrushGo.js

示例

C语言

```c
#include <stdio.h>

int main()
{
    /* 我的第一个 C 程序 */
    printf(“Hello, World! \n”);
    return 0;
}
```
显示效果

#include <stdio.h>
int main()
{
    /* 我的第一个 C 程序 */
    printf(“Hello, World! \n”);
    return 0;
}

python

```python
#!/usr/bin/python3
print(“Hello, World!”);
```
显示效果

#!/usr/bin/python3
print(“Hello, World!”);

shell

```shell
#!/usr/bin/python3
print(“Hello, World!”);
git push -f origin master ## 这里假设只有一个master分支
```

显示效果

git reflog
git reset --hard Obfafd

JavaScript

```js
if (time<10)
{
document.write(“早上好”);
}
else if (time>=10 && time<16)
{
document.write(“今天好”);
}
else
{
document.write(“晚上好!”);
}
```
显示效果

if (time<10)
{
    document.write("<b>早上好</b>");
}
else if (time>=10 && time<16)
{
    document.write("<b>今天好</b>");
}
else
{
    document.write("<b>晚上好!</b>");
}

CSS

```css

body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:“Times New Roman”;
font-size:20px;
}
```
显示效果

body
{
 background-color:#d0e4fe;
}
h1
{
 color:orange;
 text-align:center;
}
p
{
 font-family:"Times New Roman";
 font-size:20px;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值