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

Equation cannot support pandoc-eqnos or pandoc-crossref #862

Open
philher opened this issue Dec 8, 2020 · 5 comments
Open

Equation cannot support pandoc-eqnos or pandoc-crossref #862

philher opened this issue Dec 8, 2020 · 5 comments
Labels
Area: Math Issue: Feature Something brand new. Needs Discussion We haven't decided what to do.

Comments

@philher
Copy link

philher commented Dec 8, 2020

Problem

Problematic behavior

Using pandoc pandoc-crossref or pandoc-eqnos equation identifiers breaks markdown parsing, as shown in the screenshot below. The outline and code folding are also broken in the same way (Title 2 is not considered a header).
Syntax highlighting is correct.

VSCode with Markdown All in One

VSCode extension rendering

Outline

Syntax highlighting

Possibly related to #346 Equation identifier using pandoc-eqnos breaks syntax highlighting.

Expected behavior

Markdown Preview Enhanced (MPE) default renderer or with pandoc work as expected, as shown in the two screenshots below:

MPE, Pandoc renderer and --filter=pandoc-crossref filter

MPE pandoc rendering

MPE, default renderer

MPE default rendering

Furthermore, VSCode without the extension also exhibits the expected behavior:

VSCode no Markdown All in One

VSCode no extension

Outline no extension

Environment

  • VSCode version: 1.51.1
  • Markdown All in One version:
    • 3.4.0 from VSCode marketplace
    • Latest development build
  • OS: Ubuntu 20.04 LTS

How to reproduce

The previous screenshots are the results of the following snippet:

# Title 1
$$
a = b
$${#eq:e}

Refer to [@eq:e]

# Title 2
@Lemmingh
Copy link
Collaborator

Lemmingh commented Dec 8, 2020

Duplicate of #194

@Lemmingh Lemmingh marked this as a duplicate of #194 Dec 8, 2020
@Lemmingh
Copy link
Collaborator

Lemmingh commented Dec 8, 2020

Let me briefly explain what happens behind the scene:

  • The outline and folding are currently provided by VS Code.
  • VS Code relies on markdown-it.
  • VS Code loads markdown-it plugins first.
  • Our extension contributes a plugin called markdown-it-katex.
  • markdown-it-katex currently requires:
    • A line begins with $$ is the beginning of a math_block.
    • A line ends with $$ is the end of a math_block.

Thus, you're right; the parsing is changed when our extension is enabled.

In your example, markdown-it-katex regards line 2 as the beginning of a math_block. Then, it looks for a line that ends with $$. However, not found. So, it marks line 2 to the end of the file as one math_block.


I understand that this design breaks your experience.

I'm sorry to say that we are hesitant. Changing it is complex, and will be a breaking change. #839 (comment)

We are still collecting user feedback.

@philher philher changed the title Equation identifier using pandoc-eqnos or pandoc --citeproc breaks markdown parsing Equation identifier using pandoc-eqnos or pandoc --filter=pandoc-crossref breaks markdown parsing Dec 8, 2020
@philher philher changed the title Equation identifier using pandoc-eqnos or pandoc --filter=pandoc-crossref breaks markdown parsing Equation identifier using pandoc-eqnos or pandoc-crossref breaks markdown parsing Dec 8, 2020
@Lemmingh Lemmingh added Area: Math Needs Discussion We haven't decided what to do. labels Dec 8, 2020
@yzhang-gh
Copy link
Owner

Thanks for the detailed feedback @philher, and also nice summary @Lemmingh.

I cannot think of a good solution (even after 2 years). So just use the MPE preview if you need these pandoc options. And you can still have the other features from our extension.

@philher
Copy link
Author

philher commented Dec 8, 2020

Thanks for the explanation @Lemmingh (and obviously, thanks @yzhang-gh for creating this extension).

Following your explanations, I looked around at the options and found that setting "markdown.extension.math.enabled": false surprisingly does not remove the highlighting nor the completion of the latex math commands inside the block, but solves the outlining and code folding issues.
It does however disable, as expected, the math rendering in VSCode preview.
I can confirm that your extension is the one that provides highlighting and completion.

This is absolutely fine with my use case, as it allows me to use the editing features of your extension with MPE and pandoc to render the preview.


As I saw that MPE provides the option to set custom math block delimiters, maybe it would be possible to provide a setting for your extension to allow arbitrary delimiters ?
If it was possible to allow markdown-it-katex to use arbitrary delimiters and also for these delimiters to contain wildcards, one may still keep the default behavior, but also add something like the following to their user settings:

"markdown-preview-enhanced.mathBlockDelimiters": [
        [
            "$$",
            "$${#eq:*}"
        ]
    ]

Maybe it is too complex to implement, it is only something that crossed my mind.

@yzhang-gh
Copy link
Owner

Following your explanations, I looked around at the options and found that setting "markdown.extension.math.enabled": false surprisingly does not remove the highlighting nor the completion of the latex math commands inside the block, but solves the outlining and code folding issues.

Aha, it makes sense as that option only disables markdown-it-katex. Perfect!

Maybe it is too complex to implement, it is only something that crossed my mind.

Thanks. I'm not very sure but it doesn't seem to be an easy thing.

@Lemmingh Lemmingh added the Issue: Feature Something brand new. label Dec 13, 2020
@Lemmingh Lemmingh changed the title Equation identifier using pandoc-eqnos or pandoc-crossref breaks markdown parsing Equation cannot support pandoc-eqnos or pandoc-crossref Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Math Issue: Feature Something brand new. Needs Discussion We haven't decided what to do.
Projects
None yet
Development

No branches or pull requests

3 participants