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

markdown links with one preceding pair of brackets are not rendered correctly #4801

Closed
leonnicolas opened this issue May 16, 2021 · 7 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus.

Comments

@leonnicolas
Copy link

leonnicolas commented May 16, 2021

🐛 Bug Report

[][link](#some-title) is rendered to [][link](#some-title)

Links with an even number of preceding bracket pairs are rendered correctly.
Links with an odd number of preceding bracket pairs are not rendered correctly.

Pandoc, github, https://github.com/mity/md4c and docusaurus 1 render these links correctly.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. clone the docusaurus repo or take any docusaurus 2 project
  2. insert [][link](#fast-track) into website/docs/introduction.md
  3. Run yarn start
  4. Open the browser and navigate to http://localhost:3000/docs/
  5. Notice the line with [][link](#fast-track)

Expected behavior

I expected to see
[]link

Actual Behavior

I actually saw
[][link](#fast-track)

Your Environment

  • Docusaurus version used: v2.0.0-beta.0 or master

Reproducible Demo

https://codesandbox.io/s/epic-bash-ok5qk?file=/docs/intro.md
and navigate to Tutorial Intro. The broken link is the next line after the title

@leonnicolas leonnicolas 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 May 16, 2021
@nam-hle
Copy link
Contributor

nam-hle commented May 17, 2021

Can you tell me why you need the empty brackets?

@leonnicolas
Copy link
Author

Hi @nam-hle,
yes, I came across it when I was auto-generating markdown for a custom resource definition (CRD) in Kubernetes.
Here is an example: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#alertmanagerlist
Notice the []Altermanager

Generating a website with docusaurus from this markdown would not display the link to Alertmanager correctly.

@slorber
Copy link
Collaborator

slorber commented May 17, 2021

@leonnicolas I agree that the way it is rendered is surprising.

However, I still don't understand why you want to use double brackets like that. What is your intent?

Is it a bug in your auto-generation system and somehow you expect Docusaurus to handle it better than it currently does?

This is a behavior of MDX, our markdown+React parser, and unfortunately, I don't think we can fix it in the Docusaurus repo.
You can reproduce it here: https://mdxjs.com/playground/ and report it here if it's not already: https://github.com/mdx-js/mdx

And track this issue for when we upgrade MDX (as it might solve the issue):
#4029

@slorber slorber closed this as completed May 17, 2021
@leonnicolas
Copy link
Author

However, I still don't understand why you want to use double brackets like that. What is your intent?

Is it a bug in your auto-generation system and somehow you expect Docusaurus to handle it better than it currently does?

It is not a bug in the auto-generation.
[]Altermanager means you can specify a list of Altertmanager.
I think it is a golang thing and the Kubernetes community uses it in their docs a lot.
Apparently, they are not using docusaurus 2 for the generation of their websites.

This is a behavior of MDX, our markdown+React parser, and unfortunately, I don't think we can fix it in the Docusaurus repo.
You can reproduce it here: https://mdxjs.com/playground/ and report it here if it's not already: https://github.com/mdx-js/mdx

Thank you, I was not aware that you were using this parser. When I found https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-utils/src/markdownParser.ts I though you were using dark magic to parse the markdown.

@slorber
Copy link
Collaborator

slorber commented May 17, 2021

We are converting markdown to JSX in the mdx loader here if that helps: https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-mdx-loader/src/index.js#L67

@slorber
Copy link
Collaborator

slorber commented May 17, 2021

I understand your use case, however, I'm not. sure how we could easily fix it 😅

Eventually, you could replace such patterns by using HTML entities: [][link](#fast-track)

image

This shouldn't be too hard to implement a custom remark plugin to pre-process the markdown inputs before mdx

@leonnicolas
Copy link
Author

And track this issue for when we upgrade MDX (as it might solve the issue):
#4029

Yes, v2 of MDX will solve the Issue mdx-js/mdx#1559

@Josh-Cena Josh-Cena added external This issue is caused by an external dependency and not Docusaurus. and removed status: needs triage This issue has not been triaged by maintainers labels Feb 26, 2022
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 external This issue is caused by an external dependency and not Docusaurus.
Projects
None yet
Development

No branches or pull requests

4 participants