Vscode-markdown: Highlighting and auto-suggestion for code spans containing line endings

Created on 13 Mar 2020  ·  3Comments  ·  Source: yzhang-gh/vscode-markdown

What is the problem?

I want to request the hightlighting and auto-suggestion of a math block that starts and ends with a single dollar sign (not inline math) just like normal math block between 2 double dollar signs

  • Reason: Double dollar signs math block will be centered while single not. I usually use centered for the problem and left-aligned for solution or explaination.

How can I reproduce it?

Put a math block between 2 single dollar signs so that it's left aligned

image

Is there any error message in the console?

none

auto completion editor theming math Help wanted Feature

Most helpful comment

Thanks for the feedback. I even didn't know that (single dollar blocks) is a valid syntax.

All 3 comments

Thanks for the feedback. I even didn't know that (single dollar blocks) is a valid syntax.

“Single dollar signs math block” is actually inline math or bug.

Simply check the HTML output. Display math areas (math blocks) are wrapped in <span class="katex-display">, while inline math areas are not.


Before proceeding, here is an essential problem:

What's the definition of “space character”?

This extension now depends on markdown-it-katex which follows pandoc's convention:

Anything between two $ characters will be treated as TeX math. The opening $ must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus, $20,000 and $30,000 won’t parse as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won’t be treated as math delimiters.

Traditionally, line feed is regarded as a kind of space character. However, markdown-it-katex currently allows one line feed next to the $, which leads to “single dollar signs math block”:

https://github.com/yzhang-gh/markdown-it-katex/blob/4205ef9a4cea47113e9a2a055522421740c9d1c5/index.js#L23-L34

(This is just a piece of the code. The whole problem may be related to more parts.)

We have to first make it clear whether it's a bug or feature.

I think it is more of an unexpected "feature" than a bug. But I do recommend using $inline math$ instead of multiple lines.

Was this page helpful?
0 / 5 - 0 ratings