Skip to content

onBrokenMarkdownLinks errors for invalid links inside tilde codeblocks only #7800

@antonk52

Description

@antonk52

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiondomain: markdownRelated to Markdown parsing or syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions