vscode-spell-checker icon indicating copy to clipboard operation
vscode-spell-checker copied to clipboard

LaTeX in markdown document

Open PierreMarchand20 opened this issue 5 years ago • 4 comments

There is an issue about code fences #242, but I was wondering if it was possible to support latex/math environnement in markdown out of the box ?

I know that the extension has great support for LaTeX Workshop without any configuration needed, so I was wondering if it was possible to do the same for markdown (and more especially this extension, related to this issue).

I know that I can use some regex to just ignore every math environnement, but I think we could do something with the need of user-defined setting, and may be better than just ignoring everything.

PierreMarchand20 avatar Jun 19 '19 09:06 PierreMarchand20

@PierreMarchand20 thank you for bringing this up. I hope to have better support in the future for embedded languages.

For the moment, I will look at a way to exclude them. Do you have any examples of its usage in markdown?

Jason3S avatar Jun 23 '19 11:06 Jason3S

I am using the extension Markdown All in One to take notes when I am attending presentations. I am a phd in applied mathematics, so there are lots of equations, notations, greek letters, etc. Here's a small example:

# Low regularity Cauchy problem in general relativity on characteristic hypersurfaces by Olivier Graf

## Einstein equation

$(\mathcal{M},\overline{g})$ a quadratic form symmetric (-+++) where $\mathcal{M}\simeq \mathbb{R}_t\times \mathbb{R}_x^3$ and $\overline{g}=(\overline{g}_{\mu,\nu}(t,x))$. This is to be the gravitational potential

Einstein equation:
$$
[\operatorname{Ric}(\overline{g})]_{\mu,\nu}- \dfrac{1}{2} \operatorname{R}(\overline{g})\overline{g}_{\mu,\nu}= \mathrm{T}_{\mu,\nu} \qquad(EE)
$$

- $\mathrm{T}_{\mu,\nu}=0$ (vacuum)
- $\operatorname{Ric}(\overline{g})_{\mu,\nu}=\sum_{\alpha,\beta,\gamma,\delta}\overline{g}_{\alpha,\beta}\partial^2\overline{g}_{\delta,\gamma}+\sum \overline{g}_{\alpha,\beta} \partial g \partial g$ where $\partial=\partial_t,\partial_x,,\partial_y,\partial_z$
-> 10 equations

Actually, I do not see when spell check in latex environments for markdown documents could be useful. So may be, we could at least exclude them by default ?

PierreMarchand20 avatar Jun 23 '19 12:06 PierreMarchand20

I'd like this too. I can disable single-line expressions (like $e=mc^2$) with an exclusion reg exp \$.*\$, but that doesn't help with multiline expressions.

gauss256 avatar Jul 31 '21 20:07 gauss256

I've solved it by using the right regular expression exclusions. The following will exclude spell checking inside code blocks and LaTeX, whether inline or multiline. This goes into settings.json.

"cSpell.languageSettings": [
    {
      // use with Markdown files
      "languageId": "markdown",
      // Exclude code, LaTeX
      "ignoreRegExpList": [
        "\\$.*\\$",
        "\\$\\$([\\n\\(\\)]|[^(\\$\\$)])*\\$\\$",
        "`.*`",
        "```([\\n\\(\\)]|[^(\\$\\$)])*```",
      ]
    }
  ]

gauss256 avatar Aug 15 '21 04:08 gauss256