executablebooks / MyST-Parser

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

`end-before` parameter thinks it has no argument #891

Closed flying-sheep closed 3 months ago

flying-sheep commented 3 months ago

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

accessible-pygments-0.0.4 anndata-0.10.6 array-api-compat-1.5.1 asttokens-2.4.1 attrs-23.2.0 beautifulsoup4-4.12.3 bleach-6.1.0 click-8.1.7 cloudpickle-3.0.0 comm-0.2.2 contourpy-1.2.0 cycler-0.12.1 dask-2024.3.1 debugpy-1.8.1 decorator-5.1.1 defusedxml-0.7.1 dill-0.3.8 executing-2.0.1 fastjsonschema-2.19.1 fonttools-4.50.0 fsspec-2024.3.1 greenlet-3.0.3 h5py-3.10.0 harmonypy-0.0.9 hnswlib-0.8.0 igraph-0.11.4 importlib_metadata-7.1.0 ipykernel-6.29.3 ipython-8.22.2 jedi-0.19.1 joblib-1.3.2 jsonschema-4.21.1 jsonschema-specifications-2023.12.1 jupyter-cache-1.0.0 jupyter-client-8.6.1 jupyter-core-5.7.2 jupyterlab-pygments-0.3.0 kiwisolver-1.4.5 legacy-api-wrap-1.4 leidenalg-0.10.2 llvmlite-0.42.0 locket-1.0.0 markdown-it-py-3.0.0 matplotlib-3.8.3 matplotlib-inline-0.1.6 mdit-py-plugins-0.4.0 mdurl-0.1.2 mistune-3.0.2 myst-nb-1.0.0 myst-parser-2.0.0 natsort-8.4.0 nbclient-0.10.0 nbconvert-7.16.3 nbformat-5.10.3 nbsphinx-0.9.3 nest-asyncio-1.6.0 networkx-3.2.1 numba-0.59.1 numpy-1.26.4 pandas-2.2.1 pandocfilters-1.5.1 parso-0.8.3 partd-1.4.1 patsy-0.5.6 pexpect-4.9.0 pillow-10.2.0 platformdirs-4.2.0 prompt-toolkit-3.0.43 psutil-5.9.8 ptyprocess-0.7.0 pure-eval-0.2.2 pydata-sphinx-theme-0.15.2 pynndescent-0.5.11 pyparsing-3.1.2 python-dateutil-2.9.0.post0 pytz-2024.1 pyyaml-6.0.1 pyzmq-25.1.2 readthedocs-sphinx-search-0.3.2 referencing-0.34.0 rpds-py-0.18.0 sam-algorithm-1.0.2 scanpy-1.10.0rc2.dev26+gfed1786 scanpydoc-0.13.4 scikit-learn-1.4.1.post1 scipy-1.12.0 seaborn-0.13.2 session-info-1.0.0 six-1.16.0 soupsieve-2.5 sphinx-autodoc-typehints-2.0.0 sphinx-book-theme-1.1.2 sphinx-copybutton-0.5.2 sphinx-design-0.5.0 sphinxext-opengraph-0.9.1 sqlalchemy-2.0.29 stack-data-0.6.3 statsmodels-0.14.1 stdlib_list-0.10.0 tabulate-0.9.0 texttable-1.7.0 threadpoolctl-3.4.0 tinycss2-1.2.1 toolz-0.12.1 tornado-6.4 tqdm-4.66.2 traitlets-5.14.2 typing-extensions-4.10.0 tzdata-2024.1 umap-learn-0.5.5 wcwidth-0.2.13 webencodings-0.5.1 zipp-3.18.1

What operating system are you using?

Linux

Describe the Bug

I can’t use the end-before parameter:

./index.md:1: WARNING: 'include': Invalid option value for 'end-before': None: argument required but none supplied [myst.directive_parse]

Expected Behavior

Works

To Reproduce

```{include} ../README.md
:end-before: ## Citation
welcome[bot] commented 3 months 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:

chrisjsewell commented 3 months ago

Hey @flying-sheep I think this may anyway be fixed by #796, the problem is that in myst-parser 2.0.0, this is read as yaml, like so:

:end-before: ## Citation

and you can see that, because it start with an #, it is interpreted as a comment

what you need to do, is wrap it in quotes:

:end-before: "## Citation"
flying-sheep commented 3 months ago

OK, that seems to work, thanks! Weird that it’s YAML if you don’t actually use any YAML features. Why don’t you just parse it as raw text?