Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ANSI escape codes in console #2345

Merged
merged 2 commits into from Apr 3, 2022

Conversation

tomwhite
Copy link
Contributor

@tomwhite tomwhite commented Apr 2, 2022

Description

Currently, ANSI escape codes are not supported in the console:

Welcome to the Pyodide terminal emulator 馃悕
Python 3.9.5 (default, Feb 22 2022 14:12:02) on WebAssembly VM
Type "help", "copyright", "credits" or "license" for more information.
>>> print(u"\u001b[31mHello World\u001b[0m")
锟絒31mHello World锟絒0m

This is easily fixed by adding an extra javascript file that jQuery Terminal needs to render the codes.

With this change Hello World is rendered in red.

The rich library also works

>>> import micropip
>>> await micropip.install('rich')
>>> from rich import print
>>> print("Hello, [bold magenta]World[/bold magenta]!", ":vampire:")
Hello, World! 馃

(World is actually rendered in magenta.)

Checklists

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks a lot @tomwhite ! We clearly needed better color support in the REPL.

Would you mind also adding a changelog entry to https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md?

@rth
Copy link
Member

rth commented Apr 2, 2022

Also the test_console_html test needs updating.

Add a test.
@hoodmane hoodmane merged commit a69fb1b into pyodide:main Apr 3, 2022
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.

None yet

3 participants