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

PEP 1, 12: Update to reflect guidance for correct syntax highlighting #2445

Merged

Conversation

CAM-Gerlach
Copy link
Member

@CAM-Gerlach CAM-Gerlach commented Mar 19, 2022

Presently, PEP 12 doesn't mention how to ensure that the automatic syntax highlighting added in the new Sphinx/PEP 676 build system gives the intended rendered output. Therefore, this PR adds a passage to the Literal Blocks section mentioning when and how to do this for specific blocks or entire PEPs. In the process, it also updates and simplifies the existing text.

Additionally, it updates PEP 1 and PEP 12 to follow those practices themselves, so they render as intended and serve as a good example for PEP authors. A future PR will fix the other existing PEPs where the default python syntax highlighting is not giving the rendered result the original author intended, to proactively solve existing issues like #2430 ; in most cases, it can be accomplished merely by adding a single .. highlight:: language to the top of the PEP.

@CAM-Gerlach CAM-Gerlach added lint Linter-related work and linting fixes on PEPs meta Related to the repo itself and its processes labels Mar 19, 2022
@CAM-Gerlach CAM-Gerlach self-assigned this Mar 19, 2022
@CAM-Gerlach CAM-Gerlach requested review from hugovk and JelleZijlstra and removed request for warsaw and ncoghlan March 19, 2022 02:27

Random J. User <address@dom.ain>
.. code-block:: text
Copy link
Member Author

Choose a reason for hiding this comment

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

NB, I would have just added .. highlight:: text to the top of the PEP, but unlike the other languages (e.g. .. highlight:: rst in PEP 12), it doesn't change the highlight lexer of literal blocks without an explicit text language from default to text (which I can see comparing the DOM with and without it on this PEP vs. PEP 12), and results in this block still getting highlighted (incorrectly). Not sure if its a Sphinx (or Pygments) bug or an expected behavior I'm not understanding, but either way it seems to be due to a special case with the text (i.e. no highlighting) "language"/Pygments lexer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA signed lint Linter-related work and linting fixes on PEPs meta Related to the repo itself and its processes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants