title: 测试文章(三):代码与命令示例
测试文章(三):代码与命令示例
用于测试代码块是否语法高亮、可复制按钮是否正确工作,以及长命令是否自动折行。
单行命令
curl -s https://example.com/api
较长命令(应在块内折行)
sshpass -p 'yourpass' ssh -o StrictHostKeyChecking=no root@192.168.0.1 "systemctl restart some-service --now && echo done"
Shell 脚本示例
#!/usr/bin/env bash
set -euo pipefail
for f in *.log; do
echo "准备处理: $f"
head -5 "$f" > /tmp/first_$(basename "$f")
done
带中文注释的代码
# 这是一段带中文注释的示例
import os
for name in os.listdir("."): # 遍历当前目录
if name.endswith(".txt"): # 只看文本
print(name)
JSON
{
"name": "hello",
"enabled": true,
"list": [1, 2, 3]
}
以上内容用于测试高亮引擎对各种语言的分色是否正确。
0 RESPONSES
读者回应
把读完后的余温,留在这篇文章下面。