Skip to content

Add MicroPython demo page and update navigation links #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

koxudaxi
Copy link
Contributor

No description provided.

@koxudaxi koxudaxi marked this pull request as draft June 14, 2025 16:43
document.body.appendChild(pyScript);

// Remove the script element after execution
setTimeout(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you could pyScript.addEventListener('mpy:done', () => pyScript.remove()) instead

@WebReflection
Copy link

WebReflection commented Jun 18, 2025

this might be helpful, we use codedent which might simplify writing code in JS for your demos ...

import dedent from 'https://esm.run/codedent';

dedent`
  def this_is_fine():
    return "fine"
`;

/**
def this_is_fine():
  return "fine"
*/

You can then write cases like:

const options = {
  1: dedent`
    import sys
    print(sys.version)
  `),
  // ...
};

maybe worth using it? it's pretty battle tested in PyScript itself (it's a dependency) + it uses template literal tag which feels "very meta" giving this context 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants