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

feat(toc): seek anchor id from parent nodes when target is not available #3404

Merged
merged 2 commits into from Feb 13, 2019

Conversation

4 participants
@chigix
Copy link
Contributor

commented Dec 28, 2018

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:

  • Add test cases for the changes.
  • Passed the CI test.
feat(toc): seek anchor id from parent nodes when target is not available
Signed-off-by: Richard Lea <chigix@zoho.com>
@coveralls

This comment has been minimized.

Copy link

commented Dec 28, 2018

Coverage Status

Coverage increased (+0.002%) to 97.256% when pulling 25a1b7c on chigix:work-toc-fix into ccce9d6 on hexojs:master.

@coveralls

This comment has been minimized.

Copy link

commented Dec 28, 2018

Coverage Status

Coverage increased (+0.01%) to 97.266% when pulling cd7682b on chigix:work-toc-fix into ccce9d6 on hexojs:master.

@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Jan 6, 2019

@chigix
Thank you for your contribution.
I'm going to test this PR. Would you please tell me detail ? For example, how to test ...etc

@chigix

This comment has been minimized.

Copy link
Contributor Author

commented Jan 6, 2019

@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.

@@ -21,8 +21,14 @@ function tocHelper(str, options = {}) {
let lastLevel = 0;

headings.each(function() {
function getId(ele) {

This comment has been minimized.

Copy link
@tcrowe

tcrowe Jan 21, 2019

Contributor

Please bring this getId function above headings.each(...) scope.

This comment has been minimized.

Copy link
@chigix

chigix Jan 21, 2019

Author Contributor

I see. I'll push tweaks later

This comment has been minimized.

Copy link
@tcrowe

tcrowe Jan 21, 2019

Contributor

Thanks for your patience with us

@tcrowe
Copy link
Contributor

left a comment

It looks good. I will wait for resolution of the scope issue I commented on.

fix: scope of the getId function definition for `toc` helper
Signed-off-by: Richard Lea <chigix@zoho.com>
@chigix

This comment has been minimized.

Copy link
Contributor Author

commented Jan 23, 2019

@tcrowe I've pushed correction commits. May I have your review again?

@tcrowe tcrowe removed the pending-reply label Jan 23, 2019

@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Feb 12, 2019

@tcrowe
Would you like some help? Should I test it locally?

@tcrowe

This comment has been minimized.

Copy link
Contributor

commented Feb 13, 2019

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.

@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Feb 13, 2019

Hi @tcrowe

How about this?

git fetch origin pull/3404/head:BRANCHNAME
@tcrowe

This comment has been minimized.

Copy link
Contributor

commented Feb 13, 2019

@YoshinoriN Thanks! I'll try that method

@tcrowe

tcrowe approved these changes Feb 13, 2019

@tcrowe tcrowe merged commit 4c3a431 into hexojs:master Feb 13, 2019

4 checks passed

codeclimate All good!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.01%) to 97.266%
Details
@tcrowe

This comment has been minimized.

Copy link
Contributor

commented Feb 13, 2019

Thank you @chigix for the enhancement and @YoshinoriN for the PR help 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.