-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat(toc): seek anchor id from parent nodes when target is not available #3404
Conversation
Signed-off-by: Richard Lea <chigix@zoho.com>
@chigix |
@yoshinorin Thanks for reviewing. This change is mainly focusing on HTML like the case below: <div id="data-summarise" class="section level2">
<h2>Data Summarise</h2>
<p>...</p>
</div> , where the id is not assigned directly on the heading tag. However, this id anchor is still work for navigating to the target heading. So something mocking the template like the case above could be testing case for this change. |
lib/plugins/helper/toc.js
Outdated
@@ -21,8 +21,14 @@ function tocHelper(str, options = {}) { | |||
let lastLevel = 0; | |||
|
|||
headings.each(function() { | |||
function getId(ele) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bring this getId
function above headings.each(...)
scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll push tweaks later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience with us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. I will wait for resolution of the scope issue I commented on.
Signed-off-by: Richard Lea <chigix@zoho.com>
@tcrowe I've pushed correction commits. May I have your review again? |
@tcrowe |
Hey @yoshinorin I tested it but I can't remember what the result was. Do you have an easy way to get PR branches from contributors? Previously I was pulling from their repo but I think we can pull from PR number. |
Hi @tcrowe How about this? git fetch origin pull/3404/head:BRANCHNAME |
@yoshinorin Thanks! I'll try that method |
Thank you @chigix for the enhancement and @yoshinorin for the PR help 🙌 |
Signed-off-by: Richard Lea chigix@zoho.com
Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated: