如何解决他的代码块无法在hexo博客页面中工作的问题?

问题描述 投票:1回答:2

我刚刚使用github页面+ hexo来创建我的hexo博客。但是,当使用代码块时,它根本不起作用,我想知道如何修复它。 md文件中的代码是:

```js
var allp=$("div p");
allp.attr("class",function(i,n){
           return Number(n)+1;
      });
```      

```js
allp.each(function(){
        console.log(this);
        });
```

但在浏览器中,我看到的是:

 image

我已经尝试了很多方法来解决它但失败了。顺便说一下,我使用了hexo的Next主题。

markdown blogs hexo
2个回答
0
投票

我猜你需要的是这个

{% 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


0
投票

也许你可以试试这些步骤: 1.在主题的_config.yml中启用突出显示,尤其是'auto_detect';

 highlight:
      enable: true
      auto_detect: true
      line_number: true
      tab_replace:
  1. 通过hexo clean清理缓存;
  2. 通过hexo s重启服务器;
© www.soinside.com 2019 - 2024. All rights reserved.