executablebooks / MyST-Parser

An extended commonmark compliant parser, with bridges to docutils/sphinx
https://myst-parser.readthedocs.io
MIT License
735 stars 194 forks source link

Error in numbered equation when including content #755

Open andry-tino opened 1 year ago

andry-tino commented 1 year ago

Describe the bug

context The issue occurs when an MD file is created and the content is set to have:

The following MD will reproduce the issue:

# Lorem Ipsum
```{include} ./external.md

Some text followed by a numbered equation.

$$ \int \left( 2\sqrt{1+x^3} + \frac{3x^3}{\sqrt{1+x^3}} \right) dx $$ (eq001)

Another numbered equation following:

$$ \int \left( 2\sqrt{1+x^3} + \frac{3x^3}{\sqrt{1+x^3}} \right) dx $$ (eq002)

The end


**expectation**
Both equations in the file are rendered with reference numbers `(1)` and `(2)`.

**bug**
But instead the last equation gets a reference number which is missing the number, and only has the parentheses: `()`. The link actually works, but the displayed number is missing. So what gets rendered is just an open and closed parentheses.

**problem**
This is a problem because the last equation does not get a proper reference number.

### Reproduce the bug

Create a Sphinx project with this configuration:

Configuration file for the Sphinx documentation builder.

#

For the full list of built-in configuration values, see the documentation:

https://www.sphinx-doc.org/en/master/usage/configuration.html

from datetime import date

-- Project information -----------------------------------------------------

project = "myproj" copyright = f"{date.today().year}, My Proj" author = "Me" release = "1.0.0"

master_doc = "index" html_title = "My proj" language = "en"

-- General configuration ---------------------------------------------------

extensions = [ "myst_parser", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinxemoji.sphinxemoji", "sphinxcontrib.jquery", "sphinx_disqus.disqus", "sphinx_proof", ]

templates_path = ["_templates"]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

-- Options for MyST --------------------------------------------------------

myst_enable_extensions = [ "amsmath", "attrs_inline", "colon_fence", "deflist", "dollarmath", "fieldlist", "html_admonition", "html_image", "replacements", "smartquotes", "strikethrough", "substitution", ]

-- Options for HTML output -------------------------------------------------

html_theme = "sphinx_book_theme" html_title = "My project"

html_theme_options = { "repository_url": "https://github.com/mystuff", "use_repository_button": True, "use_sidenotes": True,

"announcement": "v0.19 is now out! See the Changelog for details",

}


Add a root file in the project and in the TOC add the following file:

Lorem Ipsum

Some text followed by a numbered equation.

$$ \int \left( 2\sqrt{1+x^3} + \frac{3x^3}{\sqrt{1+x^3}} \right) dx $$ (eq001)

Another numbered equation following:

$$ \int \left( 2\sqrt{1+x^3} + \frac{3x^3}{\sqrt{1+x^3}} \right) dx $$ (eq002)

The end



### List your environment

- Python 3.8.10
- Sphinx 6.1.3
- myst-parser 0.19.1
welcome[bot] commented 1 year ago

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: