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

onBrokenMarkdownLinks errors for invalid links inside tilde codeblocks only #7800

Closed
2 of 7 tasks
antonk52 opened this issue Jul 18, 2022 · 6 comments · Fixed by #7801
Closed
2 of 7 tasks

onBrokenMarkdownLinks errors for invalid links inside tilde codeblocks only #7800

antonk52 opened this issue Jul 18, 2022 · 6 comments · Fixed by #7801
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax

Comments

@antonk52
Copy link
Contributor

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

Docusaurus checks for broken links inside tilde code blocks when onBrokenMarkdownLinks is set to throw

Reproducible demo

No response

Steps to reproduce

  1. create a new docusaurus site using create-docusaurus
  2. make sure that docusaurus.config.js contains
    onBrokenLinks: 'throw',
    onBrokenMarkdownLinks: 'throw',
    
  3. Add following content to docs/intro.md
    ```
    this is an [invalid link](./path/to/a/page/that/does/not/exist.md)
    ```
    
  4. run npx docusaurus build to see the site build as expected
  5. change the codeblock from step 3 to use ~ instead of ` ie
    ~~~
    this is an [invalid link](./path/to/a/page/that/does/not/exist.md)
    ~~~
    
  6. run npx docusaurus build to see the build fail with an error
    Error: Docs markdown link couldn't be resolved: (./path/to/a/page/that/does/not/exist.md) in 
    "/Users/foo/bar/baz/docusaurus/packages/testsite/docs/intro.md" for version current
        at Array.forEach (<anonymous>)
    

Expected behavior

Docusaurus either does not check links inside codeblock or checks them for both backtick and tilde codeblocks when onBrokenMarkdownLinks is set to throw

Actual behavior

Docusaurus errors for broken markdown links only inside tilde codeblocks when onBrokenMarkdownLinks is set to throw

Your environment

  • Public source code: NA
  • Public site URL: NA
  • Docusaurus version used: Can reproduce with 2.0.0-beta.21 and 2.0.0-rc.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 16.4
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Macos

Self-service

  • I'd be willing to fix this bug myself.
@antonk52 antonk52 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 18, 2022
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Jul 18, 2022
@Josh-Cena
Copy link
Collaborator

Yep—we don't handle ~~~. I'm surprised anyone actually uses them by default.

@Josh-Cena Josh-Cena added the domain: markdown Related to Markdown parsing or syntax label Jul 18, 2022
@antonk52
Copy link
Contributor Author

If I remove the broken link from the tilde codeblock than the codeblock is rendered as you would expect. This makes me think that this is not an issue with mdxjs.

@Josh-Cena
Copy link
Collaborator

It's not—it's our own infra :) The fact that MDX accepts ~~~ means we should as well.

@Josh-Cena
Copy link
Collaborator

@antonk52 Thanks for reporting! #7801 should fix this. You can watch out for the next canary (should be in a few minutes) and give it a try.

@yangdanny97
Copy link

Yep—we don't handle ~~~. I'm surprised anyone actually uses them by default.

It's useful in a weird edge case, making a code block of markdown source code that contains a code block delimited by triple backtick.

something like

```
blah blah blah
```

@Josh-Cena
Copy link
Collaborator

In that case I would personally use four backticks...

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

Successfully merging a pull request may close this issue.

3 participants