Skip to content

Sanitize ANSI characters from generated RST#838

Merged
larsoner merged 3 commits intosphinx-gallery:masterfrom
agramfort:sanitize_ANSI
Jun 28, 2021
Merged

Sanitize ANSI characters from generated RST#838
larsoner merged 3 commits intosphinx-gallery:masterfrom
agramfort:sanitize_ANSI

Conversation

@agramfort
Copy link
Copy Markdown
Contributor

See the problem in the output block in https://braindecode.org/auto_examples/plot_sleep_staging.html#training

See all the [36m which are otherwise used to get colors in the terminal.

With this fix it looks much better !

cc @robintibor

Screenshot 2021-06-25 at 18 03 35

@agramfort
Copy link
Copy Markdown
Contributor Author

@lucyleeow what do you think? Any guidance to add a test or anything you expect from me is very welcome

@lucyleeow
Copy link
Copy Markdown
Contributor

A test similar to test_output_indentation in test_gen_rst.py that checks that the output is what you expect would do.

(This is for my future reference: https://en.wikipedia.org/wiki/ANSI_escape_code)

@agramfort
Copy link
Copy Markdown
Contributor Author

agramfort commented Jun 26, 2021 via email

Copy link
Copy Markdown
Contributor

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

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

LGTM! Just a note - we don't bother with the change log as we auto generate this from closed issues and merged PRs when doing the release.

Will wait a fews days to see if anyone else reviews, then merge!

@agramfort
Copy link
Copy Markdown
Contributor Author

I am sure @larsoner will be glad to review :)

@larsoner larsoner merged commit d2ad304 into sphinx-gallery:master Jun 28, 2021
@larsoner
Copy link
Copy Markdown
Contributor

Thanks @agramfort !

@lucyleeow lucyleeow added bug and removed enhancement labels Sep 23, 2021
sdhiscocks added a commit to sdhiscocks/sphinx-gallery that referenced this pull request Mar 10, 2023
This resolves an issue with HTML being ANSI sanitized, which can cause
issues.

For example, this breaks Plotly when rendering with plotly.min.js
embedded, due to ANSI escape in JS code, causing plots to not be
displayed.

Relates to original sphinx-gallery#838
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants