Skip to content

Commit

Permalink
adding rmd support: correcting cell_index
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBRoswell committed Jul 25, 2024
1 parent 89d9e9f commit 9be46cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vreapis/containerizer/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import bisect
import importlib
import os
import json
Expand Down Expand Up @@ -100,12 +101,14 @@ def post(self, request: Request):
process_jupytext.stdin.close()
process_jupytext.wait()
payload['notebook'] = stdout.decode()
cell_index = payload['cell_index'] - bisect.bisect_right(payload['rmarkdown_heading_indices'], payload['cell_index']) - 1
else: # if 'notebook' in payload
cell_index = payload['cell_index']
kernel = payload['kernel']
cell_index = payload['cell_index']
if isinstance(payload['notebook'], dict):
payload['notebook'] = json.dumps(payload['notebook'])
notebook = nbformat.reads(payload['notebook'], nbformat.NO_CONVERT)
common.logger.debug(len(notebook.cells))
common.logger.debug(cell_index)

source = notebook.cells[cell_index].source

Expand Down

0 comments on commit 9be46cd

Please sign in to comment.