From 8e3b8621add326793ea392dac74f17cfb4e293eb Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Tue, 5 Oct 2021 17:06:44 +0200 Subject: [PATCH] Fix python code execution for ImJoy code blocks For some reason the code highlighter do not provide the `data-lang` attribute any longer, this is a quick fix to make sure we can run js and python properly. --- assets/js/imjoy-app.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/assets/js/imjoy-app.js b/assets/js/imjoy-app.js index 571cda3c2f..93fd8fdc99 100644 --- a/assets/js/imjoy-app.js +++ b/assets/js/imjoy-app.js @@ -110,7 +110,17 @@ if (config.type === 'window') { cfg.defaults = {} } - + if (!config.lang) { + if(cfg.type.includes("python")){ + config.lang = "python" + } + else if(cfg.type.includes("javascript")){ + config.lang = "javascript" + } + else{ + console.error('"lang" is not specified, please make sure decorate the code block with the name of the language.') + } + } if (config.lang !== 'html') src = `\n${JSON.stringify(cfg, null, 1)}\n\n