Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An embeddable Python REPL, powered by Pyodide

License

NotificationsYou must be signed in to change notification settings

savannahostrowski/pyrepl-web

Repository files navigation

An embeddable Python REPL, powered by Pyodide.

Live demo

Getting started

Include the script and use the<py-repl> web component:

<scriptsrc="https://cdn.jsdelivr.net/npm/pyrepl-web/dist/pyrepl.js"></script><py-repl></py-repl>

That's it! No install needed.

Features

  • Python 3.13 in the browser via WebAssembly (Pyodide)
  • Syntax highlighting powered by Pygments
  • Tab completion for modules, functions, and variables
  • Command history with up/down arrows
  • Smart indentation for multi-line code
  • Keyboard shortcuts: Ctrl+L (clear), Ctrl+C (cancel)
  • PyPI packages: preload popular libraries
  • Startup scripts: run Python on load to set up the environment
  • Theming: built-in dark/light themes or fully custom

Attributes

AttributeDescriptionDefault
themeColor theme name (builtin or registered viawindow.pyreplThemes)catppuccin-mocha
packagesComma-separated list of PyPI packages to preloadnone
repl-titleCustom title in the header barPython REPL
srcPath to a Python startup script (see below)none
no-headerHide the header bar (boolean attribute)not set
no-buttonsHide copy/clear buttons in header (boolean attribute)not set
readonlyDisable input, display only (boolean attribute)not set
no-bannerHide the "Python 3.13" startup banner (boolean attribute)not set

Startup Scripts

Usesrc to preload a Python script that sets up the environment:

<py-replsrc="/scripts/setup.py"packages="pandas"></py-repl>

The script runs silently to populate the namespace. If you define asetup() function, it will be called after loading and its output is visible in the terminal:

# setup.pyimportpandasaspddf=pd.DataFrame({'name': ['Alice','Bob'],'age': [30,25]})defsetup():print("DataFrame loaded:")print(df)

Theming

Built-in themes:catppuccin-mocha (dark, default) andcatppuccin-latte (light).

Custom Themes

Register custom themes viawindow.pyreplThemes before loading the script. Onlybackground andforeground are required - everything else is automatically derived:

<script>window.pyreplThemes={'my-theme':{background:'#1a1b26',foreground:'#a9b1d6',}};</script><scriptsrc="https://cdn.jsdelivr.net/npm/pyrepl-web/dist/pyrepl.js"></script><py-repltheme="my-theme"></py-repl>

What gets auto-derived from your background color:

  • Terminal colors (red for errors, green for success, etc.) - from catppuccin-mocha (dark) or catppuccin-latte (light)
  • Syntax highlighting - uses the matching catppuccin Pygments style
  • Header colors - derived from the base theme

Theme Properties

PropertyDescription
backgroundTerminal background color (required)
foregroundDefault text color (required)
headerBackgroundHeader bar background (optional)
headerForegroundHeader title color (optional)
promptColorPrompt>>> color - hex (#7aa2f7) or name (green,cyan) (optional)
pygmentsStyleCustom syntax highlighting (optional, see below)

Syntax Highlighting

Syntax highlighting usesPygments. The style is chosen automatically:

  1. If your theme name matches aPygments style (e.g.,monokai,dracula), that style is used
  2. Otherwise, usescatppuccin-mocha for dark backgrounds orcatppuccin-latte for light backgrounds

For full control, provide apygmentsStyle mappingPygments tokens to colors:

<script>window.pyreplThemes={'tokyo-night':{background:'#1a1b26',foreground:'#a9b1d6',promptColor:'#bb9af7',pygmentsStyle:{'Keyword':'#bb9af7','String':'#9ece6a','Number':'#ff9e64','Comment':'#565f89','Name.Function':'#7aa2f7','Name.Builtin':'#7dcfff',}}};</script>

About

An embeddable Python REPL, powered by Pyodide

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp