mirror of https://github.com/pyodide/pyodide.git
Add pyodide to iodide dynamically using API
This commit is contained in:
parent
6914e0f8c8
commit
12bd22bab4
|
@ -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,'&').replace(/</g,'<').replace(/>/g,'>') +
|
||||
'</span>'),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue