Why Replace prismjs Code Highlighting

prismjs provides richer language support.

Replacement Steps

In your new version of Hexo (7.1.0), configure as follows:

1
2
3
4
5
syntax_highlighter: prismjs
prismjs:
preprocess: true
line_number: true
tab_replace: ''

Just change the value of syntax_highlighter to prismjs.

When replacing for the first time, clear the cache and run hexo clean && hexo s.

Replacement Effect

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 million tokens
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, "Not enough tokens");

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
title: Hello World
1
2
3
{
"title": "Hello World"
}
1
echo "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;
}
1
# Hello World