remarkjs / remark-lint

plugins to check (lint) markdown code style
https://remark.js.org
MIT License
942 stars 129 forks source link

Linter incorrectly detects references inside latex equations #229

Closed N0rbert closed 4 years ago

N0rbert commented 4 years ago

Subject of the issue

Linter tried to parse [...] inside mathematical equations.

Your environment

Steps to reproduce

Have the following RMarkdown document:

Below is LaTeX equation:

\begin{equation}
    \begin{matrix}
    \hat{\Phi}[k,l] & =
    & \left\{
    \begin{matrix}
    0 & \mbox{if } k,l = 0 \\
    S_x[k,l]\cdot H_x[k,l] + S_y[k,l]\cdot H_y[k,l] & \mbox{otherwise }
    \end{matrix} \right.
    \end{matrix}
\end{equation}

Text after equation.

The rendering is OK while using ReText editor.

Run remark on it with the following .remarkrc:

{
  "plugins": [
    "remark-preset-lint-recommended",
    "remark-preset-lint-consistent",
    "remark-preset-lint-markdown-style-guide",
    "remark-math"
 ]
}

Remark do not show any warnings about the file.

Actual behaviour

Remark shows the warnings:

  5:15-5:20  warning  Use the trailing `[]` on reference links  no-shortcut-reference-link  remark-lint
  5:15-5:20  warning  Found reference to undefined definition   no-undefined-references     remark-lint
   9:8-9:13  warning  Use the trailing `[]` on reference links  no-shortcut-reference-link  remark-lint
   9:8-9:13  warning  Found reference to undefined definition   no-undefined-references     remark-lint
  9:22-9:27  warning  Use the trailing `[]` on reference links  no-shortcut-reference-link  remark-lint
  9:22-9:27  warning  Found reference to undefined definition   no-undefined-references     remark-lint
  9:33-9:38  warning  Use the trailing `[]` on reference links  no-shortcut-reference-link  remark-lint
  9:33-9:38  warning  Found reference to undefined definition   no-undefined-references     remark-lint
  9:47-9:52  warning  Use the trailing `[]` on reference links  no-shortcut-reference-link  remark-lint
  9:47-9:52  warning  Found reference to undefined definition   no-undefined-references     remark-lint
ChristianMurphy commented 4 years ago

@N0rbert CommonMark and Github-Flavor markdown do not natively support inline Latex. The warnings above are expected because it is trying to parse the LaTeX content as markdown.

If you want to mix CommonMark with LaTex, consider using https://github.com/remarkjs/remark-math, or consider creating a parser plugins to support RMarkdown flavored Markdown https://unifiedjs.com/learn

wooorm commented 4 years ago

Christian posted just about the same, but here was the response I was typing:

Hi there! 👋

LaTeX is not part of Markdown.

New syntaxes can be supported though, bu adding a plugin to unified/remark. See unifiedjs.com for more information about us. Or search for latex + remark to see if something like that exists.

The more common math syntax in Markdown though, to my knowledge, is the one supported by remark-math.

wooorm commented 4 years ago

Closing as there isn’t something to do in this project.