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

Prevent leading whitespace in markdown code blocks from being stripped #2203

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

peytondmurray
Copy link

This PR prevents leading whitespace from being stripped from markdown code blocks before they are parsed for highlighting. For certain languages, leading whitespace is syntactically significant. Fixes jupyter/nbviewer#1021.

I tried to go as far back as I could through the git history to figure out why this was added, but it appears in the earliest tag, 4.0.0. If there is a reason to strip leading whitespaces, it's not explicitly tested for in the test suite. If you have any context around this choice, I'd be interested in hearing about it.

I also added a test to check that whitespaces aren't stripped from code blocks. I've also added a RUF001 rule to ignore uses of ambiguous unicode characters in tests/exporters/test_html.py, because of the "ɩ" which is apparently a valid APL function.

@krassowski krassowski added the bug label Jan 6, 2025
@krassowski krassowski changed the title [BUG] Prevent leading whitespace in markdown code blocks from being stripped Prevent leading whitespace in markdown code blocks from being stripped Jan 6, 2025
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.

Leading whitespace removed in code blocks with syntax highlighting
2 participants