Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include directive does not consider parser option #906

Open
dkuegler opened this issue Apr 11, 2024 · 2 comments
Open

Include directive does not consider parser option #906

dkuegler opened this issue Apr 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dkuegler
Copy link

What version of myst-parser are you using?

2.0.0

What version dependencies are you using?

absl-py==2.1.0
alabaster==0.7.16
asttokens==2.4.1
attrs==23.2.0
Babel==2.14.0
beautifulsoup4==4.12.3
bleach==6.1.0
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
comm==0.2.2
contourpy==1.2.0
cycler==0.12.1
debugpy==1.8.1
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
docutils==0.20.1
exceptiongroup==1.2.0
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.13.3
fonttools==4.50.0
fsspec==2024.3.1
furo==2024.1.29
grpcio==1.62.1
h5py==3.10.0
humanize==4.9.0
idna==3.6
imageio==2.34.0
imagesize==1.4.1
ipykernel==6.29.4
ipython==8.23.0
jedi==0.19.1
Jinja2==3.1.3
joblib==1.3.2
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jupyter_client==8.6.1
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
kiwisolver==1.4.5
lapy==1.0.1
latexcodec==3.0.0
lazy_loader==0.3
Markdown==3.6
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.8.3
matplotlib-inline==0.1.6
mdit-py-plugins==0.4.0
mdurl==0.1.2
memory-profiler==0.61.0
mistune==3.0.2
mpmath==1.3.0
myst-parser==2.0.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
nibabel==5.2.1
numpy==1.26.4
numpydoc==1.7.0
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-nccl-cu12==2.19.3
nvidia-nvjitlink-cu12==12.4.99
nvidia-nvtx-cu12==12.1.105
packaging==24.0
pandas==2.2.1
pandocfilters==1.5.1
parso==0.8.3
pexpect==4.9.0
pillow==10.3.0
platformdirs==4.2.0
plotly==5.20.0
prompt-toolkit==3.0.43
protobuf==5.26.1
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pybtex==0.24.0
pybtex-docutils==1.0.3
Pygments==2.17.2
pypandoc==1.13
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyYAML==6.0.1
pyzmq==25.1.2
referencing==0.34.0
requests==2.31.0
rich==13.7.1
rpds-py==0.18.0
scikit-image==0.22.0
scikit-learn==1.4.1.post1
scipy==1.12.0
shellingham==1.5.4
SimpleITK==2.3.1
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.5
Sphinx==7.2.6
sphinx-argparse==0.4.0
sphinx-basic-ng==1.0.0b2
sphinx-copybutton==0.5.2
sphinx-gallery==0.15.0
sphinx-issues==4.0.0
sphinx_design==0.5.0
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-bibtex==2.6.2
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-programoutput==0.17
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
stack-data==0.6.3
sympy==1.12
tabulate==0.9.0
tenacity==8.2.3
tensorboard==2.16.2
tensorboard-data-server==0.7.2
threadpoolctl==3.4.0
tifffile==2024.2.12
tinycss2==1.2.1
tomli==2.0.1
torch==2.2.2
torchio==0.19.6
torchvision==0.17.2
tornado==6.4
tqdm==4.66.2
traitlets==5.14.2
triton==2.2.0
typer==0.12.0
typer-cli==0.12.0
typer-slim==0.12.0
typing_extensions==4.10.0
tzdata==2024.1
urllib3==2.2.1
wcwidth==0.2.13
webencodings==0.5.1
Werkzeug==3.0.1
wrapt==1.16.0
yacs==0.1.8

What operating system are you using?

Linux

Describe the Bug

I have an index.rst, which includes a START.md which in turn includes from the root README.md.

The first include goes from sphinx to myst-parser, the second goes from myst to a my-st derived parser, because I am trying to fix some links due to the inclusions.

The issue is that the myst-parser ignores the parser option in the fence block.

  File "__env__/lib/python3.10/site-packages/sphinx/cmd/build.py", line 341, in main
    return build_main(argv)
  File "__env__/lib/python3.10/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "__env__/lib/python3.10/site-packages/sphinx/application.py", line 355, in build
    self.builder.build_update()
  File "__env__/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "__env__/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 313, in build
    updated_docnames = set(self.read())
  File "__env__/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 420, in read
    self._read_serial(docnames)
  File "__env__/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 441, in _read_serial
    self.read_doc(docname)
  File "__env__/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 498, in read_doc
    publisher.publish()
  File "__env__/lib/python3.10/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "__env__/lib/python3.10/site-packages/sphinx/io.py", line 105, in read
    self.parse()
  File "__env__/lib/python3.10/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "__env__/lib/python3.10/site-packages/myst_parser/parsers/sphinx_.py", line 74, in parse
    parser.render(inputstring)
  File "__env__/lib/python3.10/site-packages/markdown_it/main.py", line 291, in render
    return self.renderer.render(self.parse(src, env), self.options, env)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 235, in render
    self._render_tokens(list(tokens))
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 214, in _render_tokens
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 743, in render_fence
    return self.render_directive(token, name[1:-1], arguments)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 1686, in render_directive
    nodes_list = self.run_directive(
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 1793, in run_directive
    result = directive_instance.run()
  File "__env__/lib/python3.10/site-packages/myst_parser/mocking.py", line 471, in run
    self.renderer.nested_render_text(
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 370, in nested_render_text
    self._render_tokens(tokens)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 214, in _render_tokens
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 551, in render_ordered_list
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 558, in render_list_item
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 533, in render_bullet_list
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 558, in render_list_item
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 518, in render_paragraph
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 521, in render_inline
    self.render_children(token)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 388, in render_children
    self.rules[f"render_{child.type}"](child)
  File "__env__/lib/python3.10/site-packages/myst_parser/mdit_to_docutils/base.py", line 917, in render_link
    return self.render_link_anchor(token, href)

Expected Behavior

The parser option is considered and the appropriate parser is chosen as defined by the parser option.

To Reproduce

Create a include fence-block in a file parsed with myst-parser, that specifies a different parser (even an invalid parser should raise an error, which it does not).

@dkuegler dkuegler added the bug Something isn't working label Apr 11, 2024
Copy link

welcome bot commented Apr 11, 2024

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

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! 🎉

@dkuegler
Copy link
Author

dkuegler commented Apr 15, 2024

It seems the same is true for :relative-docs: ...
It seems to be simply ignored, but the expected behavior would be that relative docs options from multiple nested myst include blocks are combined.

Correction

any :relative-docs: value passed in the rst include block options is ignored. It seems to me that the Include.run directive/sphinx code

so : parent (project/index.rst)

Test file
-----------

.. include: subfolder/Test.md
   :parser: myst_parser.sphinx_
   :relative-docs: subfolder/
This text has a [link](../other_subfolder/example.md) to some other file. 

it is clear that in the resulting index.rst, this should link to other_subfolder/example.md, but relative-docs is not loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant