mitmproxy / mitmproxy/pdoc

Apply Python syntax highlighting to all code blocks by default

Open
#776 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
2.5k
Forks
228
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating pdoc's Markdown rendering entry point and the handling for fenced and Google-style indented code blocks. Reproduce the examples from the issue, then verify that Python highlighting and consistent margins apply by default while non-code output can still opt out with text; no specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, python
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.