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

Fails on Live URL #24

Closed
karlhorky opened this issue Aug 13, 2020 · 10 comments
Closed

Fails on Live URL #24

karlhorky opened this issue Aug 13, 2020 · 10 comments

Comments

@karlhorky
Copy link
Contributor

Hi @davidtheclark, thanks for this library!

When I run this with the following MDX content...

<a
  href="https://www.freecodecamp.org/news/a-beginners-guide-to-graphql-86f849ce1bec/"
  target="_blank"
>
  freeCodeCamp: A Beginner’s Guide to GraphQL
</a>

...it fails as in the error message below:

$ yarn remark index.md
index.md
  2:9-2:86  warning  Link to https://www.freecodecamp.org/news/a-beginners-guide-to-graphql-86f849ce1bec/" is dead  no-dead-urls  remark-lint

⚠ 1 warning

remark-lint-no-dead-urls appears to be taking the " at the end along with the link.

cc @wooorm

@karlhorky
Copy link
Contributor Author

Ahh, sorry, just realized that this is an incompatibility between Markdown and MDX.

Markdown does not allow for that syntax (at least on https://markdownlivepreview.com/):

Screen Shot 2020-08-13 at 15 24 25

I guess that it wouldn't make sense for remark to support this.

I will see what I can do with gotOptions or something...

Closing.

@wooorm
Copy link
Member

wooorm commented Aug 13, 2020

Ah yeah, HTML like this is not supported by Markdown. See CommonMark. So the URL, in GFM, is seen as an actual URL.

If you want to ignore MDX, you can use the remark-mdx plugin. Although it won’t check href props

@karlhorky
Copy link
Contributor Author

karlhorky commented Aug 13, 2020

Right, thanks for the explanation 👍

I'm looking to lint all of my .mdx files for broken links, don't have any .md files at the moment...

Hm, maybe eslint-mdx will be helpful.

Edit: ah, maybe not: mdx-js/eslint-mdx#203

@karlhorky
Copy link
Contributor Author

karlhorky commented Aug 13, 2020

Hmm... I guess I'll use patch-package to remove the " from the end of node.url. 😅

@wooorm
Copy link
Member

wooorm commented Aug 13, 2020

why not use remark-mdx?

@karlhorky
Copy link
Contributor Author

Hm, maybe I misunderstood your comment above:

If you want to ignore MDX, you can use the remark-mdx plugin. Although it won’t check href props

I don't want to ignore MDX - I want to check it :)

@karlhorky
Copy link
Contributor Author

Looking at remark-mdx, can't tell - does it work with remark-lint and remark-cli?

Edit: I guess it does - my package.json:

{
  "remarkConfig": {
    "plugins": [
      "remark-mdx",
      "remark-lint-no-dead-urls"
    ]
  }
}

@wooorm
Copy link
Member

wooorm commented Aug 13, 2020

I don't want to ignore MDX - I want to check it :)

Well, this plugin works on markdown syntax. remark-mdx makes sure MDX is understood, but it’s still a different syntax that isn’t markdown. I don’t think there exists a project like remark-lint-no-dead-links for MDX. Would <Icon src="..."> also be checked? Etc., many new problems!

@karlhorky
Copy link
Contributor Author

Ah, understood. So the links in format of <a href=""></a> are not recognized as a link with a node.url by remark-mdx, I suppose...

@wooorm
Copy link
Member

wooorm commented Aug 13, 2020

That is correct, remark/markdown does not understand HTML. And while MDX understands JSX, it does not map JSX to “equivalents” in Markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants