Closed jannismain closed 1 year ago
So first I though it would just not handle the custom $$
block syntax correctly.
However, when slightly shortening the formula by removing the exponents (but leaving the subscripts!) like this:
# Heading
Blabla (*foo*)
$$
q_{i} = q_{i+1}
$$
the false positive MD049 warning doesn't appear:
$ markdownlint-cli2 markdownlint-example.md
markdownlint-cli2 v0.5.1 (markdownlint v0.26.2)
Finding: markdownlint-example.md
Linting: 1 file(s)
Summary: 0 error(s)
This leads me to believe that this might be a bug.
There's kind of a lot going on here. Nick good to point out you shouldn't see this if you try using the VS Code extension because it implicitly includes a plug-in for parsing math blocks. CLI2 does not implicitly include plug-ins, so it thinks the content of the math block is normal Markdown. If you install and reference that plug-in in your scenario, this warning should go away. There are examples in the repo for how to do so.
What makes this scenario a little different is that MD049 does use the parser whereas the rule in the referenced issue does not. As I continue the migration to micromark, I will probably reference a similar plug-in implicitly so this scenario "just works" even in CLI2.
In conclusion, I would not consider this a bug assuming referencing the texmath plug-in suppresses the warning.
Thanks for the pointer towards the texmath plugin. With the texmath
plugin enabled, MD049 is no longer raised.
For everybody experiencing the same behavior, I have created a gist that quickly outlines the problem and solution.
Thanks!
With the configuration included in the gist linked above:
{
"markdownItPlugins": [
["markdown-it-texmath"]
]
}
the CLI works as expected now. However, the vscode extension now acts up:
[8:59:32 PM] ERROR: Exception while linting with markdownlint-cli2:
Error: Cannot find module 'markdown-it-texmath'
Require stack:
...
I have installed the requirements globally
$ npm -g list
/opt/homebrew/lib
...
+-- katex@0.16.7
+-- markdown-it-texmath@1.0.0
+-- markdownlint-cli2@0.5.1
...
Am I missing something here? Is it worth opening up another issue over at @DavidAnson/vscode-markdownlint
See https://github.com/DavidAnson/vscode-markdownlint/issues/180
A local install of the plug-in (within the project as with other dependencies) should work for both scenarios.
That fixed it! Thanks! I have updated the gist to suggest a local installation to keep compatibility with vscode-markdownlint.
In Markdown documents that include Mathjax formulas, defining math blocks like this is quite common:
Expected Behavior
No warning should be raised, as the document looks quite reasonable.
Actual Behavior
Running
markdownlint-cli2
on this document raises a seemingly unrelated issue: