Commit 12bd22ba authored by Michael Droettboom's avatar Michael Droettboom

Add pyodide to iodide dynamically using API

parent 6914e0f8
......@@ -33,4 +33,25 @@ var pyodide = {}
};
wasmXHR.send(null);
if (window.iodide !== undefined) {
iodide.addLanguage({
name: 'py',
displayName: 'Python',
keybinding: 'p',
evaluate: code => pyodide.runPython(code),
});
iodide.addOutputHandler({
shouldHandle: value => (
value.$$ !== undefined &&
value.$$.ptrType.name === 'Py*'
),
render: value => (
'<span><span role="img" aria-label="py">🐍</span>' +
pyodide.repr(value).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') +
'</span>'),
});
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment