Skip to content

Bug Report: format:docs removes empty lines inside code blocks #22167

Open

Description

@Silthus

Report

pnpm format:docs runs scripts/fix-mdx.js. The script changes the content of fenced code blocks.

removeMultipleEmptyLines in scripts/fix-mdx.js removes each empty line that follows another empty line. It does not skip fenced code blocks. normalizeIndentation in the same file skips code blocks, but this function does not.

Python style (PEP 8) puts two empty lines before a top-level function. The script changes those two empty lines to one, so a Python example in the docs no longer follows PEP 8.

To reproduce, on master at 31163f30ae:

  1. Run node scripts/fix-mdx.js contents/docs/workflows/transactional-emails/python.mdx.
  2. Run git diff.

Result: the script removes one of the two empty lines before @shared_task in the Python code block, near line 141:

 RETRYABLE_CODES = {"network_error", "idempotency_key_in_flight", "throttled", "delivery_unavailable"}

-
 @shared_task(bind=True, max_retries=5)

The script also adds an empty line between <details> and <summary> on each page that has a <details> block. That change is not in a code block, but it changes more lines than an author expects from a formatter.

Technical info

  • Script: scripts/fix-mdx.js, run by pnpm format:docs
  • Node 24, Linux

Expected outcome, or solution

The script does not change lines between the opening and closing fence of a code block.

Activity

  1. posthog commented on Nov 11, 2026

    @posthog
    Contributor

    PostHog self-driving picked up this issue. Status: Research is done.

    Somebody may already be working on it, so ask before you start a fix.

    Report (team access only): https://us.posthog.com/project/2/inbox/reports/01a1ca6f-724a-7108-8193-600572c20ba2?link_source=github_comment

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions