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

Error parsing relative path in {glue} role with subcommand #628

Open
rossbar opened this issue Sep 13, 2024 · 1 comment
Open

Error parsing relative path in {glue} role with subcommand #628

rossbar opened this issue Sep 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@rossbar
Copy link
Contributor

rossbar commented Sep 13, 2024

Describe the bug

If I use the {glue} role with a specific subcommand (e.g. {glue:text}), I get a warning that the key is not found, even when the path is specified correctly. For example, this: {glue:text}demographics.md::num_respondents` gives the following warning:

WARNING: No key 'demographics.md:' found in glue data for this document. (use `path::key`, to glue from another document) [mystnb.glue] [mystnb.glue]

The structure of the warning to me implies that there is a problem with the parsing of colons here, as the demographics.md: part of the warning is very suspicious.

Indeed when I remove the :text subcommand from the {glue} directive, the warning disappears: {glue}demographics.md::num_respondents`.

Possibly related to #591

Reproduce the bug

For ease of reproduction, I recommend creating two new dummy files in the same directory of an existing myst-nb project:

  1. Create foo.md with the following contents:
---                                                                             
jupytext:                                                                       
  formats: md:myst                                                              
  text_representation:                                                          
    format_name: myst                                                           
kernelspec:                                                                     
  display_name: Python 3                                                        
  name: python3                                                                 
---                                                                             
                                                                                
# FOO                                                                           
                                                                                
```{code-cell} ipython3                                                         
---                                                                             
tags: [hide-input]                                                              
---                                                                             
from myst_nb import glue                                                        
glue("answer", 42, display=False)                                               
```
  1. Create bar.md with the following contents:
---                                                                             
jupytext:                                                                       
  formats: md:myst                                                              
  text_representation:                                                          
    format_name: myst                                                           
kernelspec:                                                                     
  display_name: Python 3                                                        
  name: python3                                                                 
---                                                                             
                                                                                
# BAR                                                                           
                                                                                
This line warns and fails to link: {glue:text}`foo.md::answer`.                 
                                                                                
This line is fine: {glue}`foo.md::answer`.
  1. Add foo and bar to the toctree
  2. Then build the project: make html. This should give the warning:
<path/to>/bar.md:13: WARNING: No key 'foo.md:' found in glue data for this document. (use `path::key`, to glue from another document) [mystnb.glue] [mystnb.glue]

List your environment

I'm using myst-nb via sphinx directly without the jupyter-book CLI, so hopefully relevant info:

myst-nb                       1.1.1
myst-parser                   4.0.0
Sphinx                        8.0.2
@rossbar rossbar added the bug Something isn't working label Sep 13, 2024
@bsipocz
Copy link
Collaborator

bsipocz commented Sep 20, 2024

@rossbar - please open a PR once you've found a solution for this 😉

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

2 participants