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

Apply Python syntax highlighting to all code blocks by default #776

Open
mjbaldwin opened this issue Feb 12, 2025 · 1 comment
Open

Apply Python syntax highlighting to all code blocks by default #776

mjbaldwin opened this issue Feb 12, 2025 · 1 comment

Comments

@mjbaldwin
Copy link

Problem Description

Code blocks are not syntax-highlighted in Python by default. For example, compare:

    ```
    def test():
        pass
    ```

    ```py
    def test():
        pass
    ```

This generates:

Image

It can also be seen that the Python-highlighted code block has different margins.

Further, when using indentation to indicate code, according to the Google format, there is no way to specify syntax highlighting at all. It is off. E.g.:

def test():
    """
    A docstring in Google format.

    Here is a code block:

        # This example code can't be syntax-highlighted
        foo = bar
    """

Proposal

Since this project is intended for Python, it would make sense for all code blocks to be syntax highlighted by default.

It would also make sense for margins to be consistent.

But most importantly, when using indentation to indicate code in the Google format, it seems most important to syntax highlight by default, since there isn't any way of enabling it manually, the way it can be done with Markdown.

Also, if there are markdown code blocks that shouldn't have highlighting (e.g. terminal output), one solution could be to specify them as text, a language code supported on GitHub

Alternatives

If syntax highlighting isn't enabled by default for Markdown, to do it at least for Google-style indented code.

@mhils
Copy link
Member

mhils commented Feb 12, 2025

Sounds all very reasonable to me, happy to take PRs! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants