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

add maintainCase option #20

Closed
wants to merge 1 commit into from
Closed

add maintainCase option #20

wants to merge 1 commit into from

Conversation

vitaminac
Copy link

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

add maintainCase option to allow the heading to be consistent with original case of heading title

@github-actions github-actions bot added the 👋 phase/new Post is being triaged automatically label Nov 10, 2024
@wooorm
Copy link
Member

wooorm commented Nov 11, 2024

Why would that be good?

This project follows GH: they don’t do that.

It’s also not how URLs work: https://github.com/rehypejs/rehype-slug#REHYPE-SLUG goes to the same heading.

@remcohaszing
Copy link
Member

It’s also not how URLs work: https://github.com/rehypejs/rehype-slug#REHYPE-SLUG goes to the same heading.

This may be true for GitHub, but not on a page without JavaScript.

This URL navigates to the correct section: https://remcohaszing.nl/blog/creating-a-typescript-package#tsconfigjson. This URL does not: https://remcohaszing.nl/blog/creating-a-typescript-package#tsconfigjsoN.


Apart from that I agree with the points made by @wooorm. It is notable that the option exists in github-slugger though. There might be some related discussion somewhere in that project.

@wooorm
Copy link
Member

wooorm commented Nov 11, 2024

the option was just always there, from the start

@vitaminac
Copy link
Author

vitaminac commented Nov 11, 2024

Hi, without going too much deeper into my particular use case. I come up with this change because I'm migrating my personal blog from Hexo to Next.js + remark + rehype. I need to keep compatibility between two version and Hexo is generating the heading id maintaining the case.

I can confirm also that result from @remcohaszing that by default browser behaviour is URL is case sensitive without additional scripting, that is why I need make this change.

I fork this repo with corresponding change because I need it, but I think some other people will need same functionality as well. I haven't found there is any standard that specify markdown genereted HTML need to have heading id in lower case. So I think giving this flexibity to the user is important.

@vitaminac
Copy link
Author

I also plan to make the same change for https://github.com/remarkjs/remark-toc and https://github.com/syntax-tree/mdast-util-toc to have consistent behaviour between them.

@vitaminac
Copy link
Author

vitaminac commented Nov 11, 2024

this is how Hexo is generating heading id https://github.com/hexojs/hexo-renderer-marked/blob/b457f4717c28985effe9b7b7af3f8fb4b358a603/lib/renderer.js#L14, it is case sensitive.

@wooorm
Copy link
Member

wooorm commented Nov 12, 2024

While I understand your predicament, it is not of interest for this project to follow how Hexo does things. Or other arbitrary tools. Letter case is only one part, there will be many other differences.

Instead, it is recommended to follow how GH does things. You markdown files seem to be on GH. Following how GH means:
a) that your site will work
b) that links inside markdown files on GH work
c) that other tools, such as VS Code or other tools that do autocompletion can work.

There are some alternatives:

@wooorm wooorm closed this Nov 12, 2024
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Nov 12, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 👋 phase/new Post is being triaged automatically labels Nov 12, 2024
@vitaminac
Copy link
Author

Hi, I don't understand the philosophy of closing this pull request with "won't fix".

This project follows GH: they don’t do that.

Github doesn't support prefix neither, why we have this option?

it is not of interest for this project to follow how Hexo does things

My change is not copying how Hexo is generating the heading id, I'm just asking the GithubSlugger to keep the same case as original it is. This option exist in https://github.com/Flet/github-slugger why we don't want to have for this plugin?


Anything that is useful for the users without complicating the code structure should be good to have. The change is also backward compatible.

@wooorm
Copy link
Member

wooorm commented Nov 18, 2024

GH uses prefixes.

I am against GH slugger having that option.

It is intentional that people make their own plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

Successfully merging this pull request may close these issues.

3 participants