Skip to content

Conversation

@XhmikosR
Copy link
Contributor

@XhmikosR XhmikosR commented Aug 21, 2019

Works fine, but I can't figure out the tests.

Any help is welcome.

Fixes #2440

@XhmikosR
Copy link
Contributor Author

I think the proper solution would be to hook marked into the tests.

I might have a take at it tomorrow, but any help is welcome.

Changed anchor's `name` attribute to `id` since `name` is removed in HTML5.
@XhmikosR
Copy link
Contributor Author

Alright, I think we got it. Basically I only use marked in the duplicate IDs test and I check for slugger in our custom function.

The behavior should be the same, I just swapped name with id on the anchor so the generated anchors should be the same, except for cases with duplicate IDs where they didn't work anyway.

If anyone has any suggestions please let me know.

@Trott
Copy link
Member

Trott commented Aug 22, 2019

I think the proper solution would be to hook marked into the tests.

I might have a take at it tomorrow, but any help is welcome.

@phillipj @nodejs/website Anyone able to give @XhmikosR a hand with this?

anchorTitle + '" class="anchor" href="#' +
anchorTitle + '" aria-labelledby="header-' +
anchorTitle + '"></a></h' + level + '>'
const anchorId = `${slugger ? slugger.slug(anchorTitle) : anchorTitle}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the marked docs I get the impression that the slugger argument will always be provided when our custom header renderer function (anchorMarkdownHeadings()) is called by marked. Or have I misunderstood?

If it is indeed always provided, could we invoke slugger.slug() directly, without having logic checking if slugger is indeed provided? Primarily to help new contributors and our future selfs when trying to understand what this code does later, not having to graps unnecessary logic is valuable.

@phillipj
Copy link
Member

Seems like you've found a decent way of testing the duplicate IDs by using marked in the tests 👍

Other than the raised question about invoking slugger.slug(), this LGTM.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Aug 23, 2019 via email

@XhmikosR XhmikosR mentioned this pull request Aug 26, 2019
@SEWeiTung SEWeiTung merged commit dc1255e into nodejs:master Sep 2, 2019
@XhmikosR XhmikosR deleted the master-xmr-anchor-unique-ids branch September 2, 2019 05:11
@XhmikosR
Copy link
Contributor Author

XhmikosR commented Sep 2, 2019

@MaledongGit: this wasn't supposed to be squashed either. I keep the patches separate on purpose in my PRs, when it makes sense to do so. Please do not squash my patched blindly.

@silverwind
Copy link
Contributor

I think the default UI merge action is set to squash. Maybe add a note to the initial comment on PRs that should not be squashed.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Sep 2, 2019

Yeah, the thing with the merge button, is that it remembers your last choice.

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

Successfully merging this pull request may close these issues.

Duplicate heading IDs

5 participants