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

gh-126882: Fix indentation in code sample block. #126887

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

Conversation

javert42
Copy link

@javert42 javert42 commented Nov 15, 2024

Both code blocks are text from a Python REPL session. pycon is an alias for the Python REPL language used for syntax highlighting. The problem is that the lines all begin with unnecessary spaces, while pycon expects each line of input to begin with '^>>>' or '^...' (see link below).

Changing the language type to python would also work, but pycon seems to be appropriate for this case (after getting rid of the leading spaces).

This change keeps the language type (pycon) and removes the leading spaces.

Notes:
I believe this is what is being used for syntax highlighting in both GitHub and VS Code:
https://github.com/highlightjs/highlight.js/blob/c49081a84fc5de213383287b68ce2ecc238e537d/src/languages/python-repl.js

Copy link

cpython-cla-bot bot commented Nov 15, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Nov 15, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@tomasr8
Copy link
Member

tomasr8 commented Nov 15, 2024

Thanks! There's a couple more code blocks in the file that should be fixed as well

@javert42
Copy link
Author

I changed the language type from pycon to python and got rid of the leading spaces in all of the code blocks in this document.

One of the code blocks that I missed in my first commit has line-comments inserted between lines of the REPL session. Using pycon wouldn't highlight these comments because their lines don't start with >>>. Adding the >>> in front of every comment would correct the syntax, and enable comment highlighting, but it gets a bit messy. Just changing the language type to python provides the expected syntax-highlighting, and allows the author a little license to stray from strict representation of an actual REPL session.

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.

2 participants