sphinxcontrib-jupyter icon indicating copy to clipboard operation
sphinxcontrib-jupyter copied to clipboard

Sphinx crashes on code block inside itemize

Open nthiery opened this issue 6 years ago • 2 comments

Thank you again for the sphinx-contrib-jupyter example; it enabled me to reduce the crash I was getting on my own rest files to a minimal non working example:

Steps to reproduce:

  • Create a file foo.rst, with the following content, e.g. inside sphinxcontrib-jupyter.minimal:
- Create the permutation

   .. code-block:: python3

       1+1
  • Run make jupyter
make jupyter                                                                                                            master  ✱
Running Sphinx v1.6.6
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [jupyter]: targets for 3 source files that are out of date
updating environment: 3 added, 0 changed, 0 removed
reading sources... [100%] simple_notebook                                                                                                                                     
looking for now-outdated files... none found
pickling environment... done
checking consistency... /opt/sphinxcontrib-jupyter.minimal/Worksheet01-GettingHelp.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [ 33%] Worksheet01-GettingHelp                                                                                                                              
Exception occurred:
  File "/opt/sphinxcontrib-jupyter/sphinxcontrib/jupyter/writers/translate_all.py", line 328, in depart_list_item
    if self.markdown_lines[-1][-1] == "\n":
IndexError: list index out of range
The full traceback has been saved in /tmp/sphinx-err-boqtxia8.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Makefile:20 : la recette pour la cible « jupyter » a échouée
make: *** [jupyter] Erreur 1

sphinx-err-boqtxia8.log

nthiery avatar Mar 20 '18 11:03 nthiery

Thanks @nthiery. Nice bug report. Supporting directives within lists/itemize is something we will need to support.

mmcky avatar Mar 20 '18 23:03 mmcky

The tests case for lists.rst now includes embedded code-blocks. However the indentation is limited in the markdown representation, and this really only works at the moment for non-enumerated list types. The enumerated list numbering get's reset.

image

mmcky avatar Jan 25 '19 02:01 mmcky