DavidAnson / vscode-markdownlint

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

No linting support for jupyter notebook #319

Closed tvatter closed 5 months ago

tvatter commented 5 months ago

Hi,

I am aware of #199 and #174 "This is deliberate; Markdown snippets in Jupyter notebooks are not full-fledged documents and some of the linting rules don't make sense there".

However, there's been changes in how VSCode supports jupyter notebooks, see e.g. @karthiknadig in this comment

"The linting support will be handled by individual linter extensions, and not in the Jupyter Extension.

FYI, https://github.com/openlawlibrary/pygls/issues/311 just merged last week. Once that is released we can begin the work to add this support in the linter extensions."

And @karthiknadig in further commenting on the issue above:

"The limitation is when we need to see notebook as a whole document. Like when using linting, we may have to provide a merged document to the linter containing only the python cell contents. Or in cases where the linter can handle notebook itself."

See also @rebornix in this comment:

"The notebook support is now stable in VS Code and extensions can adopt this already and add linting support. IIRC Ruff already works."

My point is, there used to exist a similar issue with linting Python cells in notebooks, but this seems to have been resolved. Maybe support for linting Markdown cells could thus also be brought back?

DavidAnson commented 5 months ago

Thank you for all the links! Unfortunately, I do not see anything in these resources describing VS Code changes or what their expectations are in this scenario. As you know, this extension currently filters out schemes like notebook cells on purpose. I'm not sure what I've seen in these links changes the underlying challenge of treating each little island as a standalone document. (For example, should each cell have its own top-level heading?) I think that's what this person is trying to capture when they suggest an entirely different linter be used for notebook cells: https://github.com/microsoft/vscode-pylint/issues/20#issuecomment-1095322458. i'm not sure the scenario is common enough to justify the effort/complexity that would require.

tvatter commented 5 months ago

Sorry, I went over this again, and what they actually suggest is that extensions using the template for VS Code python tools extensions, built on top of the pygls (Python language server) library, can now extract all code cells and treat them as a standalone document.

This has already been implemented by the ruff VS Code extension, and other linter/formatter will (hopefully) follow suit.

However, I now understand that it is probably too much effort and beyond the scope of vscode-markdownlint, since it would likely entail a complete refactoring. Maybe writing a new extension using the template mentioned above and calling the markdownlint library for Node.js directly would be doable, but who knows.

DavidAnson commented 5 months ago

Okay, thank you, I agree this feels out of scope for now.