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 do not work after using JSX in the same line #4890

Closed
3 tasks done
Farrser opened this issue Jun 2, 2021 · 4 comments
Closed
3 tasks done

Markdown links do not work after using JSX in the same line #4890

Farrser opened this issue Jun 2, 2021 · 4 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: working as intended This issue is intended behavior, there's no need to take any action.

Comments

@Farrser
Copy link

Farrser commented Jun 2, 2021

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.

Description

After using a JSX component, it is not possible to use markdown links within the same line. The plain markdown text is shown instead.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

https://codesandbox.io/s/link-bug-99smz
Navigate to the docs page /docs/intro

(Write your steps here:)

  1. Use a JSX component e.g. <tag>jsx</tag>
  2. Use a markdown link in the same line [link](page.md)
  3. The link is not rendered as a link

Expected behavior

The link would be a clickable link as usual.

Actual Behavior

The link was not converted to HTML

Reproducible Demo

https://codesandbox.io/s/link-bug-99smz
Navigate to the docs page /docs/intro

@Farrser Farrser 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 Jun 2, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 2, 2021

So, your doc is:

---
sidebar_position: 1
---

# Example

export const Hello = function() {
return <span>Hello</span>
}

<Hello />! [link](./tutorial-basics/create-a-page.md) <Hello />!

It also fails in the MDX playground: https://mdxjs.com/playground/

image

It is not a Docusaurus bug, but a MDX limitation, and you should discuss that on the MDX repo instead.


You can use a <a> tag instead, not sure there's another solution if you want everything on the same line

If you don't mind having a line break (additional markdown paragraph), it's still possible to interleave markdown inside mdx by using line breaks:

# Example

export const Hello = function({children}) {
  return (
    <>
      <span>Hello</span>
      {children}
      <span>Hello</span>
    </>
  );
}

<Hello>

[link](./tutorial-basics/create-a-page.md)

</Hello>

We use something like that to display code blocks in tabs for example:
https://docusaurus.io/docs/markdown-features/code-blocks#multi-language-support-code-blocks

@slorber slorber closed this as completed Jun 2, 2021
@slorber
Copy link
Collaborator

slorber commented Jun 2, 2021

Something worth mentionning: using text before your JSX will make MDX work 😅 not sure how to remove the text prefix

Hey <Hello />! [link](./tutorial-basics/create-a-page.md) <Hello />!

@Farrser
Copy link
Author

Farrser commented Jun 2, 2021

@slorber Ah good to know. It seems that &nbsp; at the start of the line is enough to fix it, so I will do that. Definitely sounds like a bug in MDX though so I have opened an issue on the MDX repo

@ChristianMurphy
Copy link

ChristianMurphy commented Jun 2, 2021

This is how MDX 1 is intended to work (more context at mdx-js/mdx#1571 (comment)).
MDX 2 changes the behavior, if docusaurus wants the new behavior, this can be addressed with #4029

@Josh-Cena Josh-Cena added closed: working as intended This issue is intended behavior, there's no need to take any action. and removed status: needs triage This issue has not been triaged by maintainers labels Feb 23, 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 closed: working as intended This issue is intended behavior, there's no need to take any action.
Projects
None yet
Development

No branches or pull requests

4 participants