Skip to content

Conversation

@partev
Copy link
Contributor

@partev partev commented Mar 15, 2025

"sudo zypper in python3-idle" gets highlighted as Python code. specifically "in" is highlighted in green. Since this is a shell command it needs to be formatted as such.
Screenshot 2025-03-15 13 09 14


📚 Documentation preview 📚: https://cpython-previews--131295.org.readthedocs.build/en/131295/using/unix.html

"sudo zypper in python3-idle" gets highlighted as Python code. specifically "in" is highlighted in green. Since this is a shell command it needs to be formatted as such.
* For Debian and Ubuntu users::
* For Debian and Ubuntu users:

.. code-block:: shell
Copy link
Member

Choose a reason for hiding this comment

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

Do we use shell or bash in general? also are you interested in fixing the other places which use incorrect highlighting?

@picnixz
Copy link
Member

picnixz commented Mar 15, 2025

Actually in is also a keyword in shell, but I don't think it should be highlighted here. I don't really know whether we need to do something here or report to Pygments so that their highlighter is a bit more suitable. I also don't remember whether we have a better syntax highlighting language for that

@picnixz
Copy link
Member

picnixz commented Mar 15, 2025

There is a small distinction between shell (https://pygments.org/docs/lexers/#pygments.lexers.shell.BashLexer) for shell scripts and shell-session for console (https://pygments.org/docs/lexers/#pygments.lexers.shell.BashSessionLexer).

Using https://pygments.org/demo/: With Bash (equivalent to shell):

Image

With Bash Session (equivalent to shell-session):

Image

To avoid this weird formatting, I would advise using the full name zypper install instead of in (though usually we only write in indeed)


.. code-block:: shell
sudo zypper in python3-idle
Copy link
Member

Choose a reason for hiding this comment

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

As I said, this will still be highlighted as in is a valid shell keyword :( so let's use install.

Suggested change
sudo zypper in python3-idle
sudo zypper install python3-idle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what if we use shell-session lexer?

Copy link
Member

Choose a reason for hiding this comment

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

The shell-session lexer seems to work but if we put a prompt (say $) in front of the command, it doesn't work. So I'm not sure what would be the best:

image

@hugovk what do you recommend here? I think it's not the only place where we're probably mixing lexers but I think it's better if we don't highlight in here. But using shell-session without a prompt looks a bit... weird =/

Copy link
Member

Choose a reason for hiding this comment

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

@hugovk
Copy link
Member

hugovk commented Mar 15, 2025

@partev
Copy link
Contributor Author

partev commented Mar 15, 2025

Let's also take care with the indents inside bullet points.

Before:

image https://docs.python.org/3/using/unix.html#installing-idle

After:

image https://cpython-previews--131295.org.readthedocs.build/en/131295/using/unix.html#installing-idle

ok, I will submit a new pull request that just replaces "in" -> "install"

@partev
Copy link
Contributor Author

partev commented Mar 15, 2025

submitted a new pull request #131310 instead of this one

@partev partev closed this Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants