vscode-markdown-languageservice icon indicating copy to clipboard operation
vscode-markdown-languageservice copied to clipboard

Ability to provide an ignore list of reference links for markdown validation

Open jerrens opened this issue 2 years ago • 8 comments

When creating a README.md file for a GitLab repo, I received the following validation error after adding a reference of [TOC] ^1. I recognize this Table of Contents element is a feature extension added by GitLab to the standard Markdown syntax, so there was no surprise that I received the following error: No link definition found: 'TOC'.

While searching for a way to disable or ignore this one error, I ran across https://stackoverflow.com/questions/75252767/have-vscode-ignore-specific-reference-links-in-markdown-validation, but there was no known solution offered.

As suggested in the the SO thread, it would be nice if there was a way to ignore just this one 'TOC' entry via an ignore list, instead of having to to completely disable reference link validation (with "markdown.validate.referenceLinks.enabled": "ignore") for the whole project.

Is there currently a way to ignore this TOC link that I've missed?

If not possible through some current means, can the reference link validation be modified to also consider entries in the markdown.validate.ignoredLinks list or a separate setting added for providing a list of reference links that should be ignored?

The setting under markdown.validate that I did find (markdown.validate.referenceLinks.enabled) does work, but is not desirable since it turns off all reference link validation for the whole project. What I was hoping for was a way to keep that validation rule enabled, but be able to provide an explicit list of links that would be ignored.

I tried adding the following configuration, but it did not work as I hoped it would:

"markdown.validate.ignoredLinks": [ "TOC" ] 

A little more detail on the specific error reported:

[{
	"resource": "/c:/Projects/..../readme.md",
	"owner": "markdown",
	"code": "link.no-such-reference",
	"severity": 4,
	"message": "No link definition found: 'TOC'",
	"startLineNumber": 17,
	"startColumn": 2,
	"endLineNumber": 17,
	"endColumn": 5
}]

jerrens avatar Oct 02 '23 19:10 jerrens

As the author of the referenced SO post, and because I'd like to see this feature implemented/fixed, could we also ensure the interpretation of markdown.validate.ignoredLinks be some regex or GLOB patterns?

eengstrom avatar Oct 03 '23 14:10 eengstrom

This feature would be also useful to handle [Markdown] An option to highlight a "Note" and "Warning" using blockquote (Beta). I was hoping for a settings line like this to work, but right now it doesn't:

"markdown.validate.ignoredLinks": ["!NOTE", "!TIP", "!IMPORTANT", "!WARNING", "!CAUTION"] }

konrad-jamrozik avatar Dec 25 '23 23:12 konrad-jamrozik

I came across your post in SO while searching for similar issue with mdx. For mdx I fixed it using "mdx.validate.validateReferences": "ignore". I think it's a temporary fix but works for me.

Might I suggest to try something similar with markdown, "markdown.validate.referenceLinks.enabled": "ignore"

edit: As I can't replicate your issue, I can't check if the solution works or not.

HYP3R00T avatar Feb 29 '24 01:02 HYP3R00T

Related issues regarding issues with markdown validation that imho have been backlogged for way too long :)

https://github.com/microsoft/vscode-markdown-languageservice/issues/7 https://github.com/microsoft/vscode-markdown-languageservice/issues/96

firxworx avatar Apr 14 '24 20:04 firxworx

I would like to add the following:

GitHub style alerts documentation

Currently something like the following will be detected as a problem:

> [!NOTE]
> This is a GitHub note

Rendered:

[!NOTE] This is a GitHub note

nicc777 avatar May 09 '24 09:05 nicc777

I would like to add the following:

GitHub style alerts documentation

Currently something like the following will be detected as a problem:

> [!NOTE]
> This is a GitHub note

Rendered:

Note

This is a GitHub note

I'm here for this exact same issue. Would love to see a solution for this.

TjerkNan avatar May 22 '24 15:05 TjerkNan

Ressurection time.

"markdown.validate.ignoredLinks": ["!NOTE", "!TIP", "!IMPORTANT", "!WARNING", "!CAUTION"] }

Sadly, that's not how it works.

Let's say you're talking about a Python list in an MD doc, and you don't want it code-formatted.

"Lists are marked via square brackets: [list_item]"

The tooltip for 'markdown.validate.ignoredLinks' specifically says

Configure links that should not be validated. For example adding /about would not validate the link [about](/about)

(it's possible that this was implemented after the most recent posts in this issue - apologies in advance)

Adding 'list_item' to 'markdown.validate.ignoredLinks', then using 'list_item' as the link (i.e. [list_item](list_item)) works as expected (also works for references in the file footer, i.e. [list_item]: list_item).

Nasty kludge, but it is a workaround (and doesn't require creating a bogus file in the filesystem).

Probably most useful in repo-level .vscode/settings.json.

tildebyte avatar Aug 17 '25 15:08 tildebyte