Skip to content

Commit f7d7bdb

Browse files
committed
Add cell label in Quarto render status with nb_cell_yaml_options()
1 parent 6583a39 commit f7d7bdb

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/resources/jupyter/notebook.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,25 @@ def notebook_execute(options, status):
149149
# complete progress if necessary
150150
if (not quiet) and created:
151151
status("Done\n")
152-
153-
# compute total code cells (for progress)
152+
154153
current_code_cell = 1
155-
total_code_cells = sum(cell.cell_type == 'code' for cell in client.nb.cells)
154+
total_code_cells = 0
155+
cell_labels = []
156+
max_label_len = 0
156157

157-
# find max label length (for progress)
158-
max_label_len = max(len(nb_cell_yaml_options(client.nb.metadata.kernelspec.language, cell).get('label', '')) for cell in client.nb.cells)
158+
for cell in client.nb.cells:
159+
# compute total code cells (for progress)
160+
if cell.cell_type == 'code':
161+
total_code_cells += 1
162+
# map cells to their labels
163+
label = nb_cell_yaml_options(client.nb.metadata.kernelspec.language, cell).get('label', '')
164+
cell_labels.append(label)
165+
# find max label length
166+
max_label_len = max(max_label_len, len(label))
159167

160168
# execute the cells
161169
for index, cell in enumerate(client.nb.cells):
162-
# read cell options
163-
cell_options = nb_cell_yaml_options(client.nb.metadata.kernelspec.language, cell)
164-
cell_label = cell_options.get('label', '')
170+
cell_label = cell_labels[index]
165171
padding = "." * (max_label_len - len(cell_label))
166172

167173
# progress

0 commit comments

Comments
 (0)