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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add table, td, tr to allowed list of tags #2083

Merged
merged 2 commits into from Dec 18, 2023
Merged

Conversation

yuvipanda
Copy link
Contributor

pygments emits line numbers via tables, with tr and td elements (https://pygments.org/docs/formatters/#HtmlFormatter). lxml's clean_html considers table, tr and td as safe elements, but with #1854 they are now considered unsafe. So instead of displaying line numbers, the table, tr and td elements are escaped, and show up as literal HTML if trying to enable line numbers via the method introduced in #1683.

This PR adds table, tr and td as safe elements so that line numbers can continue to work.

I know that there are probably plans to move away from bleach (#1892), but this is a small and focused change so hopefully doesn't need to block on

Without this change:

image

With this change:

image

pygments emits line numbers via tables, with tr and td
elements (https://pygments.org/docs/formatters/#HtmlFormatter).
lxml's clean_html considers table, tr and td as safe elements,
but with jupyter#1854 they
are now considered unsafe. So instead of displaying line numbers,
the table, tr and td elements are escaped, and show up as literal
HTML if trying to enable line numbers via the method introduced
in jupyter#1683.

This PR adds table, tr and td as safe elements so that line numbers
can continue to work.

I know that there are probably plans to move away from bleach
(jupyter#1892), but this is
a small and focused change so hopefully doesn't need to block on
@yuvipanda
Copy link
Contributor Author

I don't think any of the test failures are related to this PR.

I did open #2084 to fix the link check failures.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Thank you!

@blink1073 blink1073 enabled auto-merge (squash) December 18, 2023 12:35
@blink1073 blink1073 merged commit c72ad76 into jupyter:main Dec 18, 2023
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants