Is your feature request related to a problem? Please describe.
Not so much a problem as a limitation of sphinx for scientific publication. Setting numfig=True in the conf.py enables automatic numbering of things like figures, tables, code-blocks, etc. Unfortunately, for code-blocks this only works if the :caption: has been defined.
Describe the solution you'd like
For scientific publication, it would be very nice if it were possible to reference a code block via numref without explicitly having to define a caption: within the code-block directive. For example:
I want to reference the following code-block with a numref:
```{code-block} python
---
name: my-code
---
print("Hello World")
```
But when I use try to reference via {numref}`my-code`, it fails unless there is a caption.
Note that the desired behavior (numref without caption) works find for tables and figures.
Describe alternatives you've considered
Pre-labeling code-blocks doesn't work either:
(my-code)=
```{code-block} python
def foo():
pass
```
Referencing the code-block like {numref}`my-code` doesn't work either
Additional context
Note that this is a limitation of sphinx, not the myst-parser. The myst-parser output is entirely consistent with rST output with sphinx (i.e. warnings and failed xrefs). Perhaps this is something that needs to be fixed upstream in sphinx, not in MyST (let me know if that's the case).
Is your feature request related to a problem? Please describe.
Not so much a problem as a limitation of sphinx for scientific publication. Setting
numfig=Truein theconf.pyenables automatic numbering of things like figures, tables, code-blocks, etc. Unfortunately, forcode-blocksthis only works if the:caption:has been defined.Describe the solution you'd like
For scientific publication, it would be very nice if it were possible to reference a code block via
numrefwithout explicitly having to define acaption:within thecode-blockdirective. For example:Note that the desired behavior (numref without caption) works find for tables and figures.
Describe alternatives you've considered
Pre-labeling code-blocks doesn't work either:
Additional context
Note that this is a limitation of sphinx, not the
myst-parser. Themyst-parseroutput is entirely consistent with rST output with sphinx (i.e. warnings and failed xrefs). Perhaps this is something that needs to be fixed upstream in sphinx, not in MyST (let me know if that's the case).