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

bug resolving multiple markdown links on the same line #9161

Closed
5 of 7 tasks
atkinsonm opened this issue Jul 20, 2023 · 10 comments
Closed
5 of 7 tasks

bug resolving multiple markdown links on the same line #9161

atkinsonm opened this issue Jul 20, 2023 · 10 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax

Comments

@atkinsonm
Copy link

atkinsonm commented Jul 20, 2023

Have you read the Contributing Guidelines on issues?

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.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Since upgrading to 2.4.1 in a dev environment, I have started to get compilation errors relating to markdown links. This bug is not present on 2.4.0.

Example error:

Error: Docs markdown link couldn't be resolved: (./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md) in "/Users/michael.atkinson/Dev/docs/devxp/desktop-devxp/008_desktop_mac_code_signing.md" for version current
    at Array.forEach (<anonymous>)

The line in question:

The setup of these Macs is described both in [003_aws_mac_manual_setup](./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md](./006_aws_mac_ansible_setup.md).

I am seeing other compilation errors of the same type as this example, all in cases where a single line of a markdown file contains more than one relative link to another markdown file. The file name does not seem to make a difference; I have examples using numbers, alphanumerics, and escaped special characters in multiple orientations.

Reproducible demo

No response

Steps to reproduce

  1. Upgrade an existing docusaurus site to 2.4.1 by updating the package.json
  2. Ensure that at least one markdown file contains multiple relative links to other markdown files on a single line
  3. build with yarn
  4. Run docusaurus start
  5. Observe compilation errors

Expected behavior

Site compiles and resolves all valid markdown links

Actual behavior

Compilation errors, site unusable

Your environment

  • Public source code: N/A, private
  • Public site URL: N/A, private
  • Docusaurus version used: 2.4.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 114.0.5735.198, Node.js v16.17.1
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS 13.4.1
  • docusaurus plugins: "@docusaurus/plugin-google-gtag": "^2.4.1", "@docusaurus/preset-classic": "^2.4.1", "@docusaurus/theme-common": "^2.4.1", "@docusaurus/theme-mermaid": "^2.4.1", "docusaurus-theme-search-typesense": "^0.12.0", "@docusaurus/module-type-aliases": "^2.4.1",

Self-service

  • I'd be willing to fix this bug myself.
@atkinsonm atkinsonm 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 Jul 20, 2023
@Josh-Cena
Copy link
Collaborator

Your error message and Markdown source don't match: the links are (./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md), with extra brackets. Could you make sure your source is actually correct?

@slorber
Copy link
Collaborator

slorber commented Jul 21, 2023

Your error message and Markdown source don't match: the links are (./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md), with extra brackets. Could you make sure your source is actually correct?

I'm not sure to understand what you mean here 🤔


Looks like I can reproduce the issue, and it only happens on the first link of a given line?

https://stackblitz.com/edit/github-zg75tv?file=docs%2Fintro.md

CleanShot 2023-07-21 at 13 33 16@2x

@atkinsonm
Copy link
Author

Your error message and Markdown source don't match: the links are (./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md), with extra brackets. Could you make sure your source is actually correct?

I included this line from my source code:

The setup of these Macs is described both in [003_aws_mac_manual_setup](./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md](./006_aws_mac_ansible_setup.md).

Please note that there are two correctly formatted markdown links, but yet the error seems to be attempting to glob them together into one.

@atkinsonm
Copy link
Author

Your error message and Markdown source don't match: the links are (./003_aws_mac_manual_setup.md) and [006_aws_mac_ansible_setup.md), with extra brackets. Could you make sure your source is actually correct?

I'm not sure to understand what you mean here 🤔

Looks like I can reproduce the issue, and it only happens on the first link of a given line?

https://stackblitz.com/edit/github-zg75tv?file=docs%2Fintro.md

CleanShot 2023-07-21 at 13 33 16@2x

The site actually fails to render for me at all, so you've gotten further than I have. This is what I see in the frontend (running a site with docusaurus start)

image

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Jul 28, 2023
@slorber
Copy link
Collaborator

slorber commented Jul 28, 2023

I can also reproduce this bug on the React-Native website, and not sure it happened before the 2.4.1 upgrade.

Example line that produces the problem is not even using the .md extension in a Markdown link, but only in text:

After this, you will be able to continue to [Native Modules (iOS)](native-modules-ios) or [Native Modules (Android)](native-modules-android) to add in some code. Make sure to read the README.md within your `MyLibrary` Directory for platform-specific instructions on how to include the project.

Note, this issue is somehow related to #9048 and happens because we use a buggy Regexp instead of processing links through the AST. We'll probably fix the Regexp for now but in the long term we should use a more robust method using the AST instead.

@Josh-Cena
Copy link
Collaborator

Does this reproduce in 3.0? Because #8927 is not backported.

@Josh-Cena Josh-Cena added the domain: markdown Related to Markdown parsing or syntax label Jul 28, 2023
@slorber
Copy link
Collaborator

slorber commented Jul 28, 2023

Does this reproduce in 3.0? Because #8927 is not backported.

I'm not sure I remember seeing this error, will investigate next week and test this PR changes against the RNW website to see if it works and is safe to backport.

@atkinsonm
Copy link
Author

atkinsonm commented Sep 20, 2023

This bug exists on version 2.4.3 as well.

@slorber
Copy link
Collaborator

slorber commented Sep 21, 2023

Yes the fix hasn't been backported unfortunately.

If we do another 2.x release I may try to backport it, otherwise you can try the v3 beta already: I'm writing the material to let you know how to upgrade right now and it will be published soon.

@slorber
Copy link
Collaborator

slorber commented Sep 25, 2023

This bug is already fixed in v3.0 beta, cf https://stackblitz.com/edit/github-zg75tv?file=package.json

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2023
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 domain: markdown Related to Markdown parsing or syntax
Projects
None yet
Development

No branches or pull requests

3 participants