AnswerDotAI / AnswerDotAI/nbdev

nbdev breaks subcaptions on figures

Open
#1,220 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
5.3k
Forks
513
Avg merge
2d 30m
Merged PRs (30d)
8

Description

See the example [here](https://quarto.org/docs/authoring/figures.html#subcaptions), Quarto can do something like the following:

```python
#| label: fig-charts
#| fig-cap: Charts
#| fig-subcap:
#| - "First"
#| - "Second"
#| layout-ncol: 2

import matplotlib.pyplot as plt
plt.plot([1,23,2,4])
plt.show()

plt.plot([8,65,23,90])
plt.show()
```
And render carts with captions:
![image](https://user-images.githubusercontent.com/7831895/201492539-6c5d5ed3-5d47-4452-a38d-b4f264a69a08.png)

Currently this will break nbdev with the following trace:

```python
Traceback (most recent call last):
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/quarto.py", line 278, in _f
try: serve_drv.main(res)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/serve_drv.py", line 22, in main
if src.suffix=='.ipynb': exec_nb(src, dst, x)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/serve_drv.py", line 16, in exec_nb
cb()(nb)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/processors.py", line 243, in __call__
def __call__(self, nb): return self.nb_proc(nb).process()
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/process.py", line 126, in process
for proc in self.procs: self._proc(proc)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/process.py", line 119, in _proc
for cell in self.nb.cells: self._process_cell(proc, cell)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/process.py", line 104, in _process_cell
if f in cell.directives_: self._process_comment(proc, cell, f)
File "/home/zach/.local/lib/python3.8/site-packages/nbdev/process.py", line 115, in _process_comment
return proc(cell, *args)
TypeError: __call__() takes 2 positional arguments but 3 were given
```

cc @seeM

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.