Skip to content

Commit

Permalink
refactor: Better support pycon syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 17, 2023
1 parent b8e07c7 commit 22b51c6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/markdown_exec/formatters/pycon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import textwrap

from markupsafe import Markup

from markdown_exec.formatters.base import base_format
Expand All @@ -16,10 +14,10 @@
def _transform_source(code: str) -> tuple[str, str]:
python_lines = []
for line in code.split("\n"):
if line.startswith(">>> "):
if line.startswith((">>> ", "... ")):
python_lines.append(line[4:])
python_code = "\n".join(python_lines)
return python_code, textwrap.indent(python_code, ">>> ")
return python_code, code


def _format_pycon(**kwargs) -> Markup:
Expand Down

0 comments on commit 22b51c6

Please # to comment.