vscode-spell-checker
vscode-spell-checker copied to clipboard
Change language in markdown code fences
Great extension! However I often make code fences in markdown, resulting in LOTS of false positive when vscode-spell-checker checks the code fence as if it was markdown code. Example:
# Some title
Bla bla this is markdown and all is good.
```latex
\usepackage[utf8]{inputenc}
```
which would result in warning on usepackage
and inputenc
. Here is a screenshot that shows the issue:
The best solution would be to dynamically switch to the code fence language locally within the code fence.
The next-best solution would be to just ignore all content without code fences.
As a workaround, I have manually enabled the latex dictionary for the folder :)
It is possible to ignore those sections:
For all file types:
"cSpell.ignoreRegExpList": [
"/^```(?:.|\\s)+?^```/mig"
],
To have it apply only to markdown:
"cSpell.languageSettings": [
{
"languageId": "markdown",
"ignoreRegExpList": [
"/^```(?:.|\\s)+?^```/mig"
]
}
]
Thanks, can confirm it works to ignore content in code fences 👍
- Any hope for locally applying dictionary in code fence according to code fence language?
- Any way of saying "Enable latex dict when editing markdown files"?
For inspiration, prettier.io actually implemented detection of language in code fences: https://prettier.io/blog/2018/04/11/1.12.0.html#support-fenced-codeblock-lang-followed-by-attributes-4153-https-githubcom-prettier-prettier-pull-4153-by-ikatyang-https-githubcom-ikatyang
Wanted behavior for markdown:
- code block: follow the language declared
- code block: if not language is declared (so it is plaintext), disable spellcheck by default or add an option to do it
- inline code: disable spellcheck by default or add an option to do it
The current behavior is a nightmare for people writing technical stuff.
Else it generate too much false positive:
Plaintext code block:
Inline code:
With regard to enable LaTeX dictionary in the markdown file, my workaround is to change the global setting in settings.json
,
"cSpell.languageSettings": [
{"languageId": "markdown", "dictionaries": ["latex"]}
]
I've posted a solution here: https://github.com/streetsidesoftware/vscode-spell-checker/issues/357?_pjax=%23repo-content-pjax-container#issuecomment-898993398
It doesn't dynamically switch to the code fence language locally within the code fence, but it excludes spell checking in code blocks, which takes care of all the false positives in them.