DavidAnson / vscode-markdownlint

Markdown linting and style checking for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
MIT License
897 stars 166 forks source link

Ignore YAML collection in frontmatter of a markdown file #283

Closed CyberSinh closed 1 year ago

CyberSinh commented 1 year ago

Hi,

---
title: 'Documentation'
taxonomy:
    category: [documentation, support, docs]
---

**Markdown text**

In the code above, the linter complains with message: "No link definition found: 'documentation, support, docs'". The linter should ignore YAML collection in frontmatter of a markdown file.

Thanks.

DavidAnson commented 1 year ago

The spaces at the front of the YAML make the default RegExp think it is not valid YAML: https://github.com/DavidAnson/markdownlint#optionsfrontmatter

You can use a .markdownlint.cli2.jsonc file to customize that RegExp via the frontMatter property: https://github.com/DavidAnson/markdownlint-cli2#markdownlint-cli2jsonc

DavidAnson commented 1 year ago

Replacing both "---" with "\s*---" in that RegExp will probably do what you want.

CyberSinh commented 1 year ago

Thanks for your answer. But it doesn't work on my side. According to regex101.com, the default regex settings should already correctly handle white space between ---.

DavidAnson commented 1 year ago

Sorry, I was typing quickly on my phone! My advice above was bad. I think this issue may be fixed in the next release of the library which is not yet integrated with the VS Code extension. I'll have a look soon with a "real" computer.

DavidAnson commented 1 year ago

Actually, based on the error message I think this is a duplicate of the following issue: https://github.com/DavidAnson/markdownlint/issues/534

It is a problem with VS Code, not the markdownlint extension.