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

Traceback when formatting an empty directive #24

Open
paugier opened this issue Feb 21, 2023 · 0 comments
Open

Traceback when formatting an empty directive #24

paugier opened this issue Feb 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@paugier
Copy link

paugier commented Feb 21, 2023

Describe the bug

Formatting an empty directive seems broken. For example formatting this

```{graphviz} ../figs/undo-simple.dot
```

leads to this:

Traceback (most recent call last):
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/bin/mdformat", line 8, in <module>
    sys.exit(run())
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/__main__.py", line 8, in run
    exit_code = mdformat._cli.run(sys.argv[1:])
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/_cli.py", line 74, in run
    formatted_str = mdformat.text(
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/_api.py", line 37, in text
    rendering = mdit.render(md)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/markdown_it/main.py", line 275, in render
    return self.renderer.render(self.parse(src, env), self.options, env)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/__init__.py", line 57, in render
    return self.render_tree(tree, options, env, finalize=finalize)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/__init__.py", line 91, in render_tree
    text = tree.render(render_context)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/_tree.py", line 11, in render
    text = renderer(self, context)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 50, in render_children
    return separator.join(out for out in render_outputs if out)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 50, in <genexpr>
    return separator.join(out for out in render_outputs if out)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/_context.py", line 49, in <genexpr>
    render_outputs = (child.render(context) for child in node.children)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat/renderer/_tree.py", line 11, in render
    text = renderer(self, context)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat_myst/_directives.py", line 64, in fence
    code_block = format_directive_content(code_block)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat_myst/_directives.py", line 75, in format_directive_content
    parse_result = parse_opts_and_content(raw_content)
  File "/home/pierre/.cache/pypoetry/virtualenvs/mercurial-jupyterbook-MIlaqlFz-py3.10/lib/python3.10/site-packages/mdformat_myst/_directives.py", line 104, in parse_opts_and_content
    line = lines.pop(0)
IndexError: pop from empty list

Reproduce the bug

Format a file with an empty directive...

List your environment

> jupyter-book --version
Jupyter Book      : 0.13.2
External ToC      : 0.3.1
MyST-Parser       : 0.15.2
MyST-NB           : 0.13.2
Sphinx Book Theme : 0.3.3
Jupyter-Cache     : 0.4.3
NbClient          : 0.5.13
@paugier paugier added the bug Something isn't working label Feb 21, 2023
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