hexo 博客页面中代码块无法工作的问题如何解决?
How to fix the isuue that he code block can`t work in hexo blog pages?
我刚刚使用 github pages + hexo 创建了我的 hexo blog.However,当使用代码块时,它根本不起作用,我想知道如何修复它。
md文件中的代码为:
```js
var allp=$("div p");
allp.attr("class",function(i,n){
return Number(n)+1;
});
```
```js
allp.each(function(){
console.log(this);
});
```
但是在浏览器中,我看到的是:
我尝试了很多方法来修复它,但都失败了。顺便说一句,我用的是hexo的Next主题
我猜你需要的是这个
{% codeblock code snippet 1 lang:js %}
var allp=$("div p");
allp.attr("class",function(i,n){
return Number(n)+1;
});
{% endcodeblock %}
{% codeblock code snippet 2 lang:js %}
allp.each(function(){
console.log(this);
});
{% endcodeblock %}
把上面的代码放到你的md文件中,你会得到this.
或许您可以尝试以下步骤:
1. 启用主题 _config.yml 的高亮,尤其是 'auto_detect';
highlight:
enable: true
auto_detect: true
line_number: true
tab_replace:
通过hexo clean
清理缓存;
按hexo s
重启服务器;
我刚刚使用 github pages + hexo 创建了我的 hexo blog.However,当使用代码块时,它根本不起作用,我想知道如何修复它。 md文件中的代码为:
```js
var allp=$("div p");
allp.attr("class",function(i,n){
return Number(n)+1;
});
```
```js
allp.each(function(){
console.log(this);
});
```
但是在浏览器中,我看到的是:
我尝试了很多方法来修复它,但都失败了。顺便说一句,我用的是hexo的Next主题
我猜你需要的是这个
{% codeblock code snippet 1 lang:js %}
var allp=$("div p");
allp.attr("class",function(i,n){
return Number(n)+1;
});
{% endcodeblock %}
{% codeblock code snippet 2 lang:js %}
allp.each(function(){
console.log(this);
});
{% endcodeblock %}
把上面的代码放到你的md文件中,你会得到this.
或许您可以尝试以下步骤:
1. 启用主题 _config.yml 的高亮,尤其是 'auto_detect';
highlight:
enable: true
auto_detect: true
line_number: true
tab_replace:
通过
hexo clean
清理缓存;按
hexo s
重启服务器;