markup icon indicating copy to clipboard operation
markup copied to clipboard

Backticks adjacent to math mode doesn't work

Open rcc-uam opened this issue 8 months ago • 14 comments

Hi guys. The following codes renders as expected:

Image

Image

However, if you remove the white spaces, then there is trouble.

Image

Image

rcc-uam avatar May 03 '25 02:05 rcc-uam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 02 '25 12:07 github-actions[bot]

hello

darkmx avatar Jul 02 '25 16:07 darkmx

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 01 '25 12:09 github-actions[bot]

hello

rcc-uam avatar Sep 01 '25 14:09 rcc-uam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 02 '25 12:11 github-actions[bot]

hello

darkmx avatar Nov 02 '25 14:11 darkmx

FWIW, I think you can do what you want to do by using triple backtick "math" blocks and no dollar signs within the math block:

r`_`s`_`n`_`t.dat

which was:

```math r_s_n_t.dat


Also new bug:

```text
<code>```math
r`_`s`_`n`_`t.dat
```</code>

Apparently causes another display issue. But hopefully this gives you something to work with @darkmx

flyingrobots avatar Nov 23 '25 19:11 flyingrobots

Er, well, I'm not sure what you were going for exactly, maybe you were going for:

r_s n_t.dat

But either way, the "```math" block has helped me get around the wonky $-math formatting.

flyingrobots avatar Nov 23 '25 19:11 flyingrobots

I was aiming for this

Image

That is, no spaces around the backticked elements.

darkmx avatar Nov 23 '25 19:11 darkmx

r\_s\_n\_t.dat
```math r\_s\_n\_t.dat ```

flyingrobots avatar Nov 23 '25 19:11 flyingrobots

This doesn't work though:

$r\_s\_n\_t.dat$

flyingrobots avatar Nov 23 '25 19:11 flyingrobots

Backticked elements are rendered with an special color in my markdown viewer, that's why I wanted to use _ and so on.

darkmx avatar Nov 23 '25 19:11 darkmx

OK I think the problem is that _ in MathJax means "subscript". So r_s becomes $r_s$. You can't have a double subscript, that's why if you write r_s_n it gets mad at you. You can escape the subscripts using a double-backslash, like this: r\\_s\\_n which shows up as $r\_s\_n$. (NOTE: In a "```math" block, you only need to use a single backslash to escape.)

I think that'll fix it for you!

flyingrobots avatar Nov 23 '25 19:11 flyingrobots

Why is this so complicated? Because "`" in MathJax was the original delimiter for mathematics. In Markdown, its was already used for "code". So they (GitHub) switched to dollar sign, like TeX. Your original example is like the parser's worst nightmare: you have backticks and dollar signs peppered all over that statement and no escapes so it's just like "code", "no math", "wait code", and it ends up thinking you're trying to do the double subscript operator, which it doesn't allow.

flyingrobots avatar Nov 23 '25 20:11 flyingrobots