-
Notifications
You must be signed in to change notification settings - Fork 86
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
Include CSS classes for 8-bit ANSI colors #378
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Heya, your example output does not contain the In [1]: import pygments
In [2]: lexer = pygments.lexers.get_lexer_by_name("myst-ansi")
In [2]: list(lexer.get_tokens("[38;5;1mHello world![0m"))
Out[2]: [(Token.Text, '[38;5;1mHello world![0m\n')]
In [3]: list(lexer.get_tokens("\x1b[38;5;1mHello world!\x1b[0m"))
Out[3]: [(Token.Color.C1, 'Hello world!'), (Token.Text, '\n')] I would ask the wasabi guys if they know of a suitable existing https://pygments.org lexer to complement their package. |
Hi @chrisjsewell! Thanks for the prompt reply! I looked at the source of the HTML document rendered using the option
When I set
To me it seems that the colour information is successfully added to the HTML document, but somehow does not show up properly. Then again, I am not really familiar at all with ANSI / pygments / lexing. |
Ah actually, I see what's going on: MyST-NB/myst_nb/_static/mystnb.css Line 130 in 2baade0
But they don't yet include https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit, div.highlight .-Color[class*=-C<N>] {
color: <hex>
}
div.highlight .-Color[class*=-BGC<N>] {
background-color: <hex>
} For |
Feel free to submit a PR 😬 |
Hi @chrisjsewell, I will give this a try! |
Thanks @chrisjsewell for your help; just opened a pull request (#379)! |
Describe the problem
I cannot get ANSI colours to show in Jupyter Notebook cell outputs.
I can see the ANSI colours in the Notebooks, and can render them successfully in HTML using
nbsphinx
.The problem is visible in my documentation here.
The output from the first code cell in the section should be rendered in red.
In my conf.py, I've set the option
nb_render_text_lexer = "myst-ansi"
.If I set `nb_render_text_lexer = "none", I can see the ANSI codes in the cell output, so I assume that the library I use for colouring the output (wasabi) works:
Link to your repository or website
https://applied-language-technology.mooc.fi/html/notebooks/part_iii/03_pattern_matching.html#examining-matches-in-context-using-concordances
Steps to reproduce
I build the documentation locally, but my conf.py is available here.
The version of Python you're using
Python 3.9.9
Your operating system
macOS 10.14.6.
Versions of your packages
Additional context
Here's the configuration of the MyST parser when building the documentation:
The text was updated successfully, but these errors were encountered: