Skip to content

nbdev breaks subcaptions on figures #1220

@muellerzr

Description

@muellerzr

See the example here, Quarto can do something like the following:

#| 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

Currently this will break nbdev with the following trace:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions