Skip to content

Read a Paragraph-Ending Line Within Its Container in pr_review.py's CODE_SPAN #3240

Closed

Description

@ptr727

The shape

CODE_SPAN in scripts/pr_review.py reads a paragraph-ending line from that line alone, bounded to three columns of indent. GitHub reads it relative to the container the paragraph sits in, so two cases still differ from the renderer.

A nested list item indented four or more columns ends its parent item's paragraph, and the span still pairs across it:

- a `b
    - c` d

GitHub renders a nested <li>c d` with the first tick unpaired. The regex masks the nested item.

A setext underline ends a paragraph at the top level and is lazy text under a list item or a quotation. The span pairs across it in both places, which is right in a container and wrong at the top level:

a `b
===
c` d

GitHub renders a b` as a heading. The regex pairs the ticks across it.

Both were left as limits in the #3227 change, since a line reader cannot know its container. The top-level setext case pairing is the behavior before that change too.

Expected

The span boundary knows the container depth of the paragraph it is in, or the limit is documented beside INTERRUPTS_PARAGRAPH and pinned by a test in each direction.

Found by the local review of the #3227 fix.

Activity

  1. added
    enhancement
    script
    on Oct 19, 2026
  2. ptr727 commented on Oct 19, 2026

    @ptr727
    OwnerAuthor

    One more case in the same class, found by the local review of the #3236 fix. A tag line inside a list item is measured against an absolute three-space bound, rather than against the item's content column:

    - item `a
        <div>
      b` c
    

    GitHub opens an HTML block at <div>, since it sits two columns past the item's content, and renders no code span. CODE_SPAN.search pairs across the line and masks the <div>. The prose gate measures this bound from the open paragraph's item content column as of #3236, so the two tools now disagree here.

  3. ptr727 commented on Oct 19, 2026

    @ptr727
    OwnerAuthor

    A third case, raised by Copilot's review of promotion #3245. The quoted block-start prefix in CODE_SPAN, {0,3}>(?: {0,4}>)* {0,4}, measures the gap after a quote marker in spaces only:

    > a `b
    >	- c` d
    

    The gap after the second > is a tab. GitHub expands it to the next tab stop, so the list item sits two columns into the quotation and ends the paragraph, and it renders no code span. CODE_SPAN.search pairs across the line. The same holds where the paragraph is not quoted. A tab's width depends on the column it starts at, so this belongs with the container reading above rather than with another spelling of the gap.

  4. ptr727 commented on Oct 20, 2026

    @ptr727
    OwnerAuthor

    A fourth case, the same container gap: a sibling list item numbered other than 1 ends the item's paragraph above it, but PARAGRAPH_BREAK only ends one at an ordered item numbered 1, which is the rule for a paragraph outside a list.

    1. a `b
    2. c` d
    

    GitHub renders two items and no span. CODE_SPAN pairs the two backticks across the items.

    The fix for #3235 reads inline HTML on the same PARAGRAPH_BREAK, so an unclosed opener carries the gap too:

    1. a <!-- b
    2. c `x` -->
    

    GitHub renders x as a span in item 2. The reader runs the comment across the items to the later -->, so it finds no span there.

  5. added a commit that references this issue on Oct 20, 2026
    01495c0
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

    enhancementscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions