Skip to content

TOC seems not suitable when skipping heading levels #2137

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

Open
selfboot opened this issue Sep 4, 2016 · 8 comments · May be fixed by #5653
Open

TOC seems not suitable when skipping heading levels #2137

selfboot opened this issue Sep 4, 2016 · 8 comments · May be fixed by #5653
Labels
bug Something isn't working

Comments

@selfboot
Copy link

selfboot commented Sep 4, 2016

When there is a link in the header, such as:

# Header1

Content....

# [Header2](http://selfboot.cn)

content...

## Sub Header

content...

Then the toc generated seems a bit strange, just looks like:

<ol class="toc">
<li class="toc-item toc-level-1">
...
</ol>
<li class="toc-item toc-level-1"><a class="toc-link" href="#Sub Header"><span class="toc-number">2.</span> <span class="toc-text">Sub Header</span></a></li>
...

Should not all the <li class="toc-item toc-level-*"> be in ol.toc ?

Version:

$ hexo --version
hexo: 3.2.2
hexo-cli: 1.0.2
os: Darwin 15.6.0 darwin x64
http_parser: 2.7.0
node: 6.4.0
v8: 5.0.71.60
uv: 1.9.1
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 57.1
modules: 48
openssl: 1.0.2h

And in this blog, there is a live demo.

@NoahDragon
Copy link
Member

Seems it has been resolved on your site.

@selfboot
Copy link
Author

selfboot commented May 4, 2017

I have not resolved this issue.

As you can see, in my blog, the structure is as follows:

image

But it should be as follows:

image

@NoahDragon NoahDragon reopened this May 4, 2017
@NoahDragon NoahDragon added the bug Something isn't working label May 4, 2017
@SukkaW
Copy link
Member

SukkaW commented Dec 20, 2019

I think I might know what is happened here.

The title timeit in your post is <h1> (#) while the subtitle under (likes 命令行接口 and Python 接口) are in <h3> (###).

So far there is no better way to fix that issue, all we could suggest is not to skip any level of headings now.

We will keep this issue opened until we came up with some better idea to solve this.

@stevenjoezhang
Copy link
Member

stevenjoezhang commented Mar 9, 2020

@stevenjoezhang stevenjoezhang changed the title TOC seems not suitable when there is a link in headers. TOC seems not suitable when skipping heading levels Apr 28, 2020
@SukkaW
Copy link
Member

SukkaW commented Jun 20, 2020

@stevenjoezhang It appears that @ppoffice has already fix the issue in his icarus theme. Maybe we could borrow some idea from it.

@stevenjoezhang
Copy link
Member

@jerryc127
Copy link

是否有计划修复这个问题?
@stevenjoezhang @SukkaW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants