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锚点初始化失败? #974

Closed
ivanberry opened this issue Jul 4, 2016 · 8 comments
Closed

TOC锚点初始化失败? #974

ivanberry opened this issue Jul 4, 2016 · 8 comments
Labels

Comments

@ivanberry
Copy link

TOC跳转链接应该是与文章标题对应的,但是md渲染后文章标题并没有对应id

期望:

## 标题 //mardown title
<h2 id="标题">标题</h2>

查看源码后,应该不是js部分有错误,js部分只是取出响应属性值,并取得offset

  $('.post-toc a').on('click', function (e) {
    e.preventDefault();
    var targetSelector = NexT.utils.escapeSelector(this.getAttribute('href')); //undefined
    var offset = $(targetSelector).offset().top; //理所当然就报错了

    hasVelocity ?
      html.velocity('stop').velocity('scroll', {
        offset: offset  + 'px',
        mobileHA: false
      }) :
      $('html, body').stop().animate({
        scrollTop: offset
      }, 500);
  });

是md渲染出来的问题?

线上地址,可以查看我的地址:任意文章

@pujiaxun
Copy link

你是用markdown-it渲染的嘛,我也遇到这个问题了0.0

@ivanberry
Copy link
Author

对,对,就是它,难道是它的问题!!

On Aug 12, 2016 16:42, "Jason" [email protected] wrote:

你是用markdown-it渲染的嘛,我也遇到这个问题了0.0


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#974 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMgWTto4eFN19mVhxs1pGxQ44xHQJTjyks5qfDIPgaJpZM4JEFXg
.

@pujiaxun
Copy link

是的
官方markdown-it好像拒绝实现这个功能,就是不渲染heading的id导致锚点失效

所以我改造了一下hexo-markdown-it……

——Jason

在 2016年8月12日,23:16,Tab [email protected] 写道:

对,对,就是它,难道是它的问题!!

On Aug 12, 2016 16:42, "Jason" [email protected] wrote:

你是用markdown-it渲染的嘛,我也遇到这个问题了0.0


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#974 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMgWTto4eFN19mVhxs1pGxQ44xHQJTjyks5qfDIPgaJpZM4JEFXg
.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@pujiaxun
Copy link

@wuxubj
Copy link
Contributor

wuxubj commented Aug 15, 2016

我的博客没有这样的问题啊,点击文章内小标题都会跳转到文章对应位置。
如果确定markdown语法没有问题,那么可能是生成html时出了问题,建议重新安装Hexo。

@pujiaxun
Copy link

@wuxubj 不是。。真的是markdown-it的实现有差别。 默认Marked插件是没有问题的,因为他GFM支持的不太好,我就换成了Markdown-it,但是他不生成标题的id导致无法获取锚点。

@ivan-nginx
Copy link
Collaborator

@ivanberry dont understand u, write in English if not solved. If solved, close it please. Thank's!

@khiav223577
Copy link

It's hexo-renderer-markdown-it's bug.

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

No branches or pull requests

5 participants