Skip to content

Commit cc1c803

Browse files
committed
Add cell label in Quarto render status with nb_cell_yaml_options()
1 parent 8583db5 commit cc1c803

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/resources/jupyter/notebook.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,27 @@ def notebook_execute(options, status):
153153
# compute total code cells (for progress)
154154
current_code_cell = 1
155155
total_code_cells = sum(cell.cell_type == 'code' for cell in client.nb.cells)
156-
157-
# find max id length (for progress)
158-
max_id_len = max(len(cell.id) for cell in client.nb.cells)
159156

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)
159+
160160
# execute the cells
161161
for index, cell in enumerate(client.nb.cells):
162-
# find cell id
163-
source_list = cell.source.split('\n')
164-
cell_id = cell.id if any(s.startswith("#| label") or s.startswith("#| id") for s in source_list) else ""
165-
padding = "." * (max_id_len - len(cell_id))
166-
162+
# read cell options
163+
cell_options = nb_cell_yaml_options(client.nb.metadata.kernelspec.language, cell)
164+
cell_label = cell_options.get('label', '')
165+
padding = "." * (max_label_len - len(cell_label))
166+
167167
# progress
168168
progress = (not quiet) and cell.cell_type == 'code' and index > 0
169169
if progress:
170170
status(" Cell {0}/{1}: '{2}'{3}...".format(
171171
current_code_cell - 1,
172172
total_code_cells - 1,
173-
cell_id,
173+
cell_label,
174174
padding
175175
))
176-
176+
177177
# clear cell output
178178
cell = cell_clear_output(cell)
179179

0 commit comments

Comments
 (0)