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

Adding class to markdown header puts class name in URL #2419

Closed
adamstevens87 opened this issue Mar 16, 2020 · 4 comments · Fixed by #2426
Closed

Adding class to markdown header puts class name in URL #2419

adamstevens87 opened this issue Mar 16, 2020 · 4 comments · Fixed by #2426
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@adamstevens87
Copy link

Example:

### My Great Heading {#custom-id}

Output URL:
http://someurl.com#my-great-heading-custom-id

Expected output URL:
http://someurl.com#my-great-heading

I am adding a custom class to my header to add styling as needed. However, this impacts the URL of the header in an unexpected (and unwanted) way.

I also tried:

### <span class="class-name"> Title </span>

but this output is even worse! :)

@adamstevens87 adamstevens87 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Mar 16, 2020
@lex111
Copy link
Contributor

lex111 commented Mar 16, 2020

This syntax is used to define a custom ids for the headings, see https://www.markdownguide.org/extended-syntax/#heading-ids for details.

So when you use this code:

### My Great Heading {#custom-id}

URL will be like this: http://someurl.com#custom-id

However, I think we can add support for this feature in v2. @yangshun agree with this?


But in fact, this does not apply to the topic of this issue.

@adamstevens87 you just need to use the explicitly appropriate HTML tag to make it possible to style it:

<h3 class="class-name"> Title </h3>

@lex111 lex111 removed the bug An error in the Docusaurus core causing instability or issues with its execution label Mar 16, 2020
@adamstevens87
Copy link
Author

Hi @lex111 - thanks for you answer - I reaslie the title was misleading, but I also tried:

General

And the output URL is:

https://dosomeutl.com#span-classfaq-header-general-span

I wanted to use the ## notation so the title was added to the sidebar.

Is there something I am missing?

@lex111
Copy link
Contributor

lex111 commented Mar 17, 2020

@adamstevens87 I see, then when generating slug we will not consider any HTML, and in the end slug will be clean (just general in your case).

@lex111 lex111 added the bug An error in the Docusaurus core causing instability or issues with its execution label Mar 17, 2020
@lex111 lex111 added this to the v2.0.0-alpha.49 milestone Mar 17, 2020
@adamstevens87
Copy link
Author

Thanks for confirming.

@lex111 lex111 removed the status: needs triage This issue has not been triaged by maintainers label Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants