From ee90e89d1c6b21674963a6dd45f8581a6e353587 Mon Sep 17 00:00:00 2001 From: Jason Weill <93281816+JasonWeill@users.noreply.github.com> Date: Thu, 13 Apr 2023 10:18:52 -0700 Subject: [PATCH] Strips prefix and suffix (#60) --- packages/jupyter-ai-magics/jupyter_ai_magics/magics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py index 55874a84e..9fb891682 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/magics.py @@ -1,5 +1,5 @@ -import os import json +import os import warnings from typing import Optional @@ -189,6 +189,8 @@ def ai(self, line, cell=None): # if the user wants code, add another cell with the output. if args.format == 'code': + # Strip leading and trailing triple-backticks + output = output.removeprefix('```\n').removesuffix('\n```') new_cell_payload = dict( source='set_next_input', text=output,