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

Can't escape $ in math #7

Closed
4 tasks done
nvlang opened this issue May 15, 2024 · 2 comments
Closed
4 tasks done

Can't escape $ in math #7

nvlang opened this issue May 15, 2024 · 2 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@nvlang
Copy link

nvlang commented May 15, 2024

Initial checklist

Affected packages and versions

[email protected]

Link to runnable example

https://github.com/nvlang/micromark-extension-math-bug

Steps to reproduce

  1. Clone https://github.com/nvlang/micromark-extension-math-bug
  2. Run npm i (or pnpm i)
  3. Run node index.js

Expected behavior

$ a \$ b $ should be parsed as an inline math node with
content a \$ b.

Actual behavior

$ a \$ b $ is parsed as follows:

  • $ a \$: math node with content a \
  • b $: text node with content b $

Runtime

Node v16

Package manager

pnpm

OS

macOS

Build and bundle tools

No response


Edit

I just looked at this package's unit tests and noticed that this seems to be the expected behavior. I'm guessing the idea is to replicate the behavior from backticks. I suppose that this makes this not a bug report, but rather a matter of personal preference. However, I do believe that there is an argument in favor of the behavior I expected: it mirrors the behavior inside TeX documents.

I understand that there are advantages to having $ behave like backticks; the main one that comes to mind is the ability to have math within text within math, i.e., $$\text{$x$}$$ $\text{$x$}$. However, that behavior is still reconcilable with the behavior I expected.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 15, 2024
@nvlang nvlang changed the title Can't escape \$ in math Can't escape $ in math May 15, 2024
@wooorm
Copy link
Member

wooorm commented May 15, 2024

Right, you already answered this yourself. This is intended behavior. It is documented clearly: https://github.com/micromark/micromark-extension-math#syntax.

People probably know how code works in markdown. Or if they don’t, but then they can learn it, and it applies to both code and math.

I love not having to use escapes in code (and math). And it annoys me to have to do it in HTML.

You can use $$a $ b$$ for your case.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label May 15, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants