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

mdformat escapes backslashes in LaTeX expressions #325

Closed
ycrouin opened this issue May 24, 2022 · 4 comments
Closed

mdformat escapes backslashes in LaTeX expressions #325

ycrouin opened this issue May 24, 2022 · 4 comments
Labels
question Further information is requested

Comments

@ycrouin
Copy link

ycrouin commented May 24, 2022

Describe the bug

Before formatting
Screenshot from 2022-05-24 14-40-37
After formatting
Screenshot from 2022-05-24 14-40-55

Reproduce the bug

I'm using pre-commit with the following configuration

# .pre-commit.config.yaml
repos:
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.3.1
    hooks:
      - id: nbqa
        entry: nbqa mdformat --number --nbqa-md
        name: nbqa-mdformat
        alias: nbqa-mdformat
        additional_dependencies: [mdformat==0.7.14, mdformat_tables==0.4.1]

pre-commit run --all-files

List your environment

  • pre-commit: 2.19.0
  • python: 3.8.10
  • os: Linux Ubuntu 20.04
@ycrouin ycrouin added the bug Something isn't working label May 24, 2022
@welcome
Copy link

welcome bot commented May 24, 2022

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@hukkin
Copy link
Owner

hukkin commented May 24, 2022

Thanks for the issue!

What do you use to render your Markdown? Mdformat is CommonMark compatible and CommonMark doesn't support LaTeX syntax. The added backslash will not change rendered CommonMark. It may change rendering of some other Markdown flavor/extension though. You'd probably need a plugin to support that though, unless you wrap your LaTeX in a code block.

@hukkin hukkin added question Further information is requested and removed bug Something isn't working labels May 24, 2022
@ycrouin
Copy link
Author

ycrouin commented May 27, 2022

Hey 👋 Thanks for this cool module and for the fast answer!

I was not aware LaTeX is not supported by CommonMark. I close the issue since I guess it's out of the scope.

The above screenshots are from a Jupyter notebook in VsCode. It is rendered the same in Jupyter Lab. Jupyter Lab uses MathJax to render LaTeX and supports GitHub flavored markdown. But I'm not sure how everything is rendered under the hood.

Do you know of such plugins or are they yet to be created 😅 ?

@hukkin
Copy link
Owner

hukkin commented Nov 24, 2022

Do you know of such plugins or are they yet to be created ?

Sorry for the delay.

pip install mdformat-myst

should bring support for the LaTeX syntax used in MyST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants