现在已支持以下代码的语法高亮。基本对齐我们的开发语言。
为了与 Mardkown的代码不冲突,现在仅支持使用 [syntax]
标签支持语法高亮。
语法高亮格式为:
Code: Select all
[syntax=language]
[/syntax]
下表为所支持的编程语言,如果有新增语言需求,可以在论坛回贴中提出要求。
Code: Select all
Language Style Name
C++ cpp
C c
CSS css
Diff diff
HTML, XML xml
Ini ini
JSON json
Java java
JavaScript javascript
Makefile makefile
Markdown markdown
Python python
Shell Session shell
Dust dust
Go go
Lua lua
TypeScript typescript
以下为 C 代码的高亮展示
Code: Select all
[syntax=c]
#include <stdio.h>
int main() {
double a, b, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
// Calculating product
product = a * b;
// %.2lf displays number up to 2 decimal point
printf("Product = %.2lf", product);
return 0;
}
[/syntex]
Code: Select all
#include <stdio.h>
int main() {
double a, b, product;
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
// Calculating product
product = a * b;
// %.2lf displays number up to 2 decimal point
printf("Product = %.2lf", product);
return 0;
}
JS 语言格式
代码
Code: Select all
[syntax=javascript]
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
[/syntax]
展示
Code: Select all
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>