Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown All In One breaks Math block syntax highlighting #1008

Closed
bhuynhdev opened this issue Sep 3, 2021 · 10 comments
Closed

Markdown All In One breaks Math block syntax highlighting #1008

bhuynhdev opened this issue Sep 3, 2021 · 10 comments
Labels
Area: Editor theming Decorations and highlighting in editor. Area: Math Res: External Outside of our control/codebase.

Comments

@bhuynhdev
Copy link

bhuynhdev commented Sep 3, 2021

Problem

After I installed the "Markdown all in one" extension in VsCode, the enclosing highlighting of math block is not working correctly any more. Removing the extension and the highlighting works again, so I figured I would make an issue here.

image

As seen in the image, the "$$" signs at the end of the Math block is understood as something different. Therefore, subsequent markdown is not highlighted correctly, even though they are rendered correctly.

Other features of Markdown All in one still works, including Latex autocomplete/Intellisense inside the math block.

Configuration

No other extension (such as Markdown+math) were installed. I tried turning off the "math.enabled" option, but it didn't resolve the issue. Assigning the value to true also did not resolve the issue.

"markdown.extension.math.enabled": false

Environment

Lubuntu 20.04
Markdown all in one 3.4.0 (should be the newest version because I just installed it through VsCode Market 5 min ago)
VsCode 1.60.0

Diagnostic data

There seems to be nothing in the Debug Console

@Lemmingh Lemmingh added Area: Editor theming Decorations and highlighting in editor. Area: Math Res: External Outside of our control/codebase. labels Sep 3, 2021
@Lemmingh
Copy link
Collaborator

Lemmingh commented Sep 3, 2021

Conflict with VS Code's built-in Markdown Math (vscode.markdown-math) extension.

We both inject TM grammar for the same (at least similar) thing:
https://github.com/microsoft/vscode/blob/4e37c907d238758879047c4218756ff5d99dae82/extensions/markdown-math/package.json#L33-L59

"grammars": [
{
"scopeName": "markdown.math_display",
"path": "./syntaxes/math_display.markdown.tmLanguage.json",
"injectTo": [
"text.html.markdown"
]
},
{
"scopeName": "markdown.math_inline",
"path": "./syntaxes/math_inline.markdown.tmLanguage.json",
"injectTo": [
"text.html.markdown"
]
},
{
"scopeName": "text.katex",
"path": "./syntaxes/katex.tmLanguage.json"
}
]

The merge result is unpredictable.


contributes.grammars is a "declarative" thing in VS Code's world. The only way to remove it is disabling the corresponding extension.

I'm sorry that you have to disable one of them.

@yzhang-gh
Copy link
Owner

yzhang-gh commented Sep 4, 2021

A tip about how to disable the vscode.markdown-math

disable markdown-math

#986 (comment)

@bhuynhdev
Copy link
Author

Thanks. Disabling the builtin Markdown Math (as shown by @yzhang-gh) did work. Now the math blocks gets separated correctly. I think this is something that should be stated in the documentation.

@Lemmingh
Copy link
Collaborator

Lemmingh commented Sep 6, 2021

@YangLinzhuo
Copy link

Today I ran into this problem too.
image

The method here works fine but need to disable the builtin markdown-math plugin. I accidently find another solution. Here it is:

$$f(n) = \begin{cases}
0, & n = 0; \\
1, & n = 1; \\
f(n-1) + f(n-2), & n > 1
\end{cases}$$

just not add newline after open $$ and before closing $$. Then highlight works fine.

image

While this method may looks ugly... Just for a record here.
Anyway, I will disable the builtin one.

@yfzhao20
Copy link

yfzhao20 commented Oct 5, 2021

我觉着可以给出一个选项,单独关闭 markdown all in one 的数学高亮。两个插件的数学高亮还是有区别的,比如行内公式,markdown all in one 无法识别$号前有空格的情况:
image
而内置插件可以:
image

或者是调整一下识别行内公式的方法。

@Lemmingh
Copy link
Collaborator

Lemmingh commented Oct 5, 2021

单独关闭 Markdown All in One 的数学高亮

不可能单独关闭,文档已经解释了。

#1008 (comment)


两个插件的数学高亮还是有区别的

我们用的语法其实不一样。

#955 (comment)


调整一下识别行内公式的方法

我也想逃出 TextMate grammar 的框框。但现阶段很难。😢

#846 (comment)

@Firestar-Reimu
Copy link

我也遇到相同的问题

我没有使用Markdown-math插件,这个是已经内置了吗?

"markdown.extension.math.enabled": false 是可以解决的,增加这一行后,所有的$$都不高亮了

@Lemmingh
Copy link
Collaborator

是的。这里讨论的 Markdown Math 就是 VS Code 内置的 vscode.markdown-math

Yes. The "Markdown Math" in this thread refers to the VS Code's built-in vscode.markdown-math.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Editor theming Decorations and highlighting in editor. Area: Math Res: External Outside of our control/codebase.
Projects
None yet
Development

No branches or pull requests

7 participants
@yzhang-gh @YangLinzhuo @Lemmingh @bhuynhdev @Firestar-Reimu @yfzhao20 and others