Closed nvlang closed 6 months ago
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.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
Initial checklist
Affected packages and versions
micromark-extension-math@3.0.0
Link to runnable example
https://github.com/nvlang/micromark-extension-math-bug
Steps to reproduce
npm i
(orpnpm i
)node index.js
Expected behavior
$ a \$ b $
should be parsed as an inline math node with contenta \$ b
.Actual behavior
$ a \$ b $
is parsed as follows:$ a \$
: math node with contenta \
b $
: text node with contentb $
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.