为什么要替换 prismjs 代码高亮
prismjs 提供了更丰富的语言支持。
替换步骤
在你的新版本 Hexo (7.1.0) 中,进行以下配置:
1 2 3 4 5
| syntax_highlighter: prismjs prismjs: preprocess: true line_number: true tab_replace: ''
|
只需将 syntax_highlighter
的值改为 prismjs
。
首次替换时,请清除缓存并运行 hexo clean && hexo s
。
替换效果
1
| console.log('Hello World!');
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| // SPDX-License-Identifier: MIT pragma solidity ^0.8.0;
contract R4AGv2 { string public name = "R4AGv2"; uint256 public totalSupply = 1000000000000000000000000; // 1 百万代币 address public owner;
mapping(address => uint256) public balanceOf;
constructor() { balanceOf[msg.sender] = totalSupply; owner = msg.sender; }
function transfer(address to, uint256 amount) external { require(balanceOf[msg.sender] >= amount, "代币不足");
balanceOf[msg.sender] -= amount; balanceOf[to] += amount; } }
|
1 2
| def hello(): print('Hello World!')
|
1 2 3 4 5
| public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
|
1 2 3 4 5 6
| #include <stdio.h>
int main() { printf("Hello World!\n"); return 0; }
|
1 2 3 4 5 6
| #include <iostream>
int main() { std::cout << "Hello World!" << std::endl; return 0; }
|
1 2 3 4 5 6 7 8 9
| <!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> <h1>Hello World!</h1> </body> </html>
|
1 2 3
| body { background-color: #f0f0f0; }
|
1 2 3
| { "title": "Hello World" }
|
1 2
| - Hello World! + Hello Hexo!
|
1 2 3 4 5 6
| server { listen 80; server_name example.com; root /var/www/html; index index.html; }
|