Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOC] anchor problem #4

Closed
zhangyu0806 opened this issue Oct 13, 2017 · 8 comments
Closed

[TOC] anchor problem #4

zhangyu0806 opened this issue Oct 13, 2017 · 8 comments

Comments

@zhangyu0806
Copy link

zhangyu0806 commented Oct 13, 2017

Hexo 导航栏 TOC 锚点无效,且只生成一级目录
之前用hexo-renderer-markdown-it 渲染 Markdown 的话,会出现导航无法使用,且只出现一级标题的情况。
TOC锚点初始化失败? #974
解决方案如下 ↓
Cannot render headings with ids? #40


重新安装 hexo-renderer-markdown-it-plus ,似乎之前的 hexo-renderer-markdown-it 存在的问题继承下来了。
且用 @[toc] 生成 Table of Contents 后,导航栏的层级错乱,无法导航。

这个是否可以用 Cannot render headings with ids? #40 此办法修复?

@CHENXCHEN
Copy link
Owner

CHENXCHEN commented Oct 13, 2017

关于TOC锚点,我使用的是markdown-it-toc-and-anchor,并且在我的测试下是有效的,您可以看我的这篇blog,点击右侧Table of Contents,其下的导航锚点是有效的,样例文章
并且在本地测试,通过@[TOC]生成的锚点效果上来看也是正常的。
ps: hexo-renderer-markdown-it 插件没有集成完整的TOC的相关插件和语法所以有bug
image
image
image

@CHENXCHEN
Copy link
Owner

CHENXCHEN commented Oct 13, 2017

@zhangyu0806 也许以下几种方法可以帮您解决这个问题:

  1. hexo clean之后再测试hexo g
  2. 删除node_modules并重新安装依赖包npm install
  3. 升级hexo版本

@zhangyu0806
Copy link
Author

zhangyu0806 commented Oct 14, 2017

@CHENXCHEN 感谢作者耐心解答。之前没注意到 Hexo 配置文件中少添加了 render:
image

另,你的说明文档里没写这行,容易造成误解:)

@CHENXCHEN
Copy link
Owner

@zhangyu0806 markdown_it_plus下没有render这一行..,文档里有写配置信息

@zhangyu0806
Copy link
Author

markdown_it_plus:
    highlight: true
    html: true
    xhtmlOut: true
    breaks: true
    langPrefix:
    linkify: true
    typographer:
    quotes: “”‘’
    pre_class: highlight

重新改了 Hexo 配置文件, 之前配置后没 hexo clean 。

@zhangyu0806
Copy link
Author

请问,如果想把 @[TOC] 改成 [TOC],需要怎么修改?

@CHENXCHEN
Copy link
Owner

markdown-it-toc-and-anchor插件没有提供这个参数,需要修改这个插件内相关代码

@zhangyu0806
Copy link
Author

不懂代码…… 试着改掉里面的 @[toc],报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants