pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Mangled code block when using --docformat google

Open michael1006 opened this issue 10 months ago • 1 comments

Problem Description

When using --docformat google, content inside my triple-backtick code block is being mangled.

Steps to reproduce the behavior:

  1. Attach the following docstring to a function:
    """
    Lorem dolor sit amet.

    ```
    ABC:
        DEF
    GHI
    ```
    """
  1. Compile using --docformat google

  2. Resulting <pre><code> element contains:


###### ABC:
> DEF

GHI

When expected content is:

ABC:
    DEF
GHI

See reproducer file:

2025-02-11 - pdoc code block.zip

Note that when the colon is removed after "ABC", it does not get mangled. The text is not dependent on "ABC", it can be anything.

System Information

pdoc: 15.0.1 Python: 3.12.8 Platform: macOS-15.3-arm64-arm-64bit

michael1006 avatar Feb 11 '25 23:02 michael1006

Clearly a bug in https://github.com/mitmproxy/pdoc/blob/main/pdoc/docstrings.py, contributions welcome! 😃

mhils avatar Feb 12 '25 07:02 mhils