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

Wrong RegExp to determine the markdown links. #4

Open
ulivz opened this issue Oct 7, 2019 · 2 comments
Open

Wrong RegExp to determine the markdown links. #4

ulivz opened this issue Oct 7, 2019 · 2 comments
Assignees

Comments

@ulivz
Copy link
Contributor

ulivz commented Oct 7, 2019

Step to reproduce

When the markdown file contains typescript like:

- Type: `{ [path: string]: Object }`

We'll get following error:

File is not found: [path: string]: Object }` (/path/to/foo.md:86:12)
@whxaxes whxaxes self-assigned this Jan 19, 2020
@cdauth
Copy link

cdauth commented Apr 17, 2021

I'm also running into this. Here are some more cases where this goes wrong:

  • [`{ [markerId: number]: Marker }`](./types#marker) leads to File is not found: [`{ [markerId: number]: Marker }`](./types#marker) (it detects the whole link but fails)
  • (`{ [fieldName: string]: string }`): The filled out form fields of the marker. By default, this is a null-prototype object to avoid prototype pollution. Have a look at [marker/line data](./advanced#marker-line-data) for more details. leads to File is not found: [fieldName: string]: string }`): The filled out form fields of the marker. By default, this is a null-prototype object to avoid prototype pollution. Have a look at [marker/line data](./advanced#marker-line-data) for more details. (Somehow it thinks the whole line is a link.)

@cdauth
Copy link

cdauth commented Apr 17, 2021

After thinking about whether I can write an easy fix for this, I came to the conclusion that with the current approach of check-md this is not possible. Markdown is far too complex to parse it using a simple regular expression. Consider the following examples:

[`[test](test)`](test)
[\[](test) [\]](test)
`[test` [test](test) `test](test)`
``test`[test`` [test](test) ``test`](test)``

In my opinion, a proper markdown parser would need to be used.

As a workaround, I'm writing my documentation like this for now:

- Type: <code>{ &#91;path: string&#93;: Object }</code>

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

No branches or pull requests

3 participants