Skip to content

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

Open
@mjbaldwin

Description

@mjbaldwin

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions