MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

$$ equation reference is not identified unless preceded by a blank line

Open tillahoffmann opened this issue 1 year ago • 3 comments

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

pydata-sphinx-theme==0.15.2
sphinx-book-theme==1.1.2
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
docutils==0.20.1

What operating system are you using?

Mac

Describe the Bug

Equation labels in dollar math are not identified unless the equation is preceded by a blank line. For example, the following two versions work as expected.

First.

$$
a = b + c
$$ (my-eqn)

{eq}`my-eqn`
First.

$$
a = b + c
$$ (my-eqn)
{eq}`my-eqn`

But this version fails with a missing reference.

First.
$$
a = b + c
$$ (my-eqn)

{eq}`my-eqn`

My conf.py contains

myst_enable_extensions = [
    "dollarmath",
]
myst_dmath_double_inline = True
myst_dmath_allow_labels = True

Expected Behavior

Equation labels are identified even if no blank line precedes the equation.

To Reproduce

See above.

tillahoffmann avatar Mar 29 '24 17:03 tillahoffmann

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

welcome[bot] avatar Mar 29 '24 17:03 welcome[bot]

This is an interesting Issue. The use of spaces, number of spaces, and blank lines is one aspect of MyST-Parser that I'm trying to understand better and be consistent.

From reading the MyST-Parser documentation on Paragraphs , it says,


Paragraphs are block of text separated by a blank line.

From the above, I would say there's a requirement for a blank line between the paragraph block (First.) and the $$ extension. When there is is no blank line, the MyST-Parser reads everything until a blank as a paragraph block, thus my-eqn is not defined, resulting in the missing reference.

72757373656c6c avatar Apr 03 '24 04:04 72757373656c6c

Well, an equation is not a paragraph. We commonly say ", where A is something, and B is something". So, if I put a blank line after the equation, will the incident of "where A is something, and B is something" look strange? Meanwhile, if I missed a blank line after an equation segment, the next time I use a pair of dollar signs to include an inline equation will not be compiled properly.

I suggest we implement a parser to allow equation environment put inside of a pair of double-dollar to put closely in a paragram with other text content.

i2000s avatar May 30 '24 06:05 i2000s