Skip to content

Commit

Permalink
Playground: Handle statements on same line
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Nov 29, 2024
1 parent 2a8b99b commit 4cc004d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/src/py/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,16 @@ def execute(cmd, no_except=True, inline=False, init='', g=None):

# Format source as Python console statements
start = node.lineno
col_start = node.col_offset
end = node.end_lineno
col_end = node.end_col_offset
stmt = lines[start - 1: end]
command = ''
for i, line in enumerate(stmt, 0):
if i == 0:
stmt[i] = '>>> ' + line
stmt[i] = '>>> ' + line[col_start:col_end]
else:
stmt[i] = '... ' + line
stmt[i] = '... ' + line[col_start:col_end]
command += '\n'.join(stmt)
if isinstance(node, AST_BLOCKS):
command += '\n... '
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ extra_javascript:
- https://unpkg.com/[email protected]/dist/mermaid.min.js
- playground-config-4f0f586c.js
- https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js
- assets/coloraide-extras/extra-notebook-UmZ-G8NV.js
- assets/coloraide-extras/extra-notebook-C-gQPRdO.js

extra:
social:
Expand Down

0 comments on commit 4cc004d

Please sign in to comment.